请教jquery高手,new $.sosor(options)有什么作用,this指的又是什么?init方法为什么要写到prototype中
请教jquery高手,new $.sosor(options)有什么作用,this指的又是什么?init方法为什么要写到prototype中
;(function(){
$.extend($.fn,{
soso : function(options){
var so = new $.sosor(options);
if(so.settings.onsubmit){
alert("onsubmit");
}
}
});
//constructor for sosor
$.sosor = function(options){
this.settings = $.extend({}, $.sosor.defaults,options);
this.init();
};
$.extend($.sosor,{
defaults : {
rules : {},
onsubmit : true,
messages : {}
},
messages : {
required: "This field is required.",
remote: "Please fix this field."
},
prototype : {
init : function(){
var rules = this.settings.rules.username;
var msg = this.settings.messages.required
alert(msg);
}
}
})
})(jQuery);