Skip to main content

You should also wrap your code into a namespace with IIFE to avoid global conflict and immediate execution.

i.e.

(function (token, undefined) {
    token.init = function () {
        var self = this;
        //add event handler
        $('#friend').on('keyup', function (event) {
            //test data to make sure its usable
            self.testData( $(this) , event  );

        });
    };
}(window.token = window.token || {}));

You should also wrap your code into a namespace with IIFE to avoid global conflict and immediate execution.

i.e.

(function (token, undefined) {
    token.init = function () {
        var self = this;
        //add event handler
        $('#friend').on('keyup', function (event) {
            //test data to make sure its usable
            self.testData( $(this) , event  );

        });
    };
}(window.token = window.token || {}));

You should also wrap your code into a namespace with IIFE to avoid global conflict.

i.e.

(function (token, undefined) {
    token.init = function () {
        var self = this;
        //add event handler
        $('#friend').on('keyup', function (event) {
            //test data to make sure its usable
            self.testData( $(this) , event  );

        });
    };
}(window.token = window.token || {}));
Source Link

You should also wrap your code into a namespace with IIFE to avoid global conflict and immediate execution.

i.e.

(function (token, undefined) {
    token.init = function () {
        var self = this;
        //add event handler
        $('#friend').on('keyup', function (event) {
            //test data to make sure its usable
            self.testData( $(this) , event  );

        });
    };
}(window.token = window.token || {}));