请教jquery高手,new $.sosor(options)有什么作用,this指的又是什么?init方法为什么要写到prototype中

linbooooo1987 2012-02-22 10:42:47
请教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);
...全文
118 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

87,989

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧