How to make $.tpt.prototype.socket.on("connect", function() {});
in the following class?
skeleton.js:
var socket = io.connect('http://localhost:3003');
socket.on("connect", function () {
});
(function ($) {
var uuid = {};
$.tpt = function (options) {
this.boot();
};
$.tpt.prototype.boot = function(msg) {
alert("page loaded");
};
//attach that events of socket here how??
})(jQuery);
var socket = io.connect('http://localhost:3003'); socket.on("connect", function () { }); (function ($) { var uuid = {}; $.tpt = function (options) { this.boot(); this.socketOn('connect',function(){}); }; $.tpt.prototype.boot = function(msg) { alert("page loaded"); }; $.tpt.prototype.socketOn = function(event,fn){ socket.on(event,fn); }; })(jQuery);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.