如何在下一课中制作$.tpt.prototype.socket.on("connect", function() {});
?
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);
答案 0 :(得分:1)
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);