Posted on 2008-05-08 13:19
leekiang 閱讀(642)
評論(1) 編輯 收藏 所屬分類:
jquery(進去而已)
1,jquery插件開發模式
http://www.learningjquery.com/2007/10/a-plugin-development-patternThere are a few requirements that I feel this pattern handles nicely:
(1)、Claim only a single name in the jQuery namespace
(2)、Accept an options argument to control plugin behavior
(3、Provide public access to default plugin settings
(4、Provide public access to secondary functions (as applicable)
(5、Keep private functions private
(6、Support the Metadata Plugin
(7,無論何時候,當你的代碼出現each時,你應該重寫代碼來構造一個插件
2,jquery源碼初步研究(插件擴展機制)
http://hi.baidu.com/uniquejava/blog/item/d55a2e12140f6953f819b821.html3,傳入回調函數的一種寫法,不知可有更好的
?? 傳參時的寫法: callback:'test()'
?? 調用時的寫法:
??? if(options.callback) eval(options.callback);
? 來源
http://www.heartstringz.net/blog/posts/view/jquery-countdown-plugin4,(function($){
?$.fn.extend({
??????? ?plusin:function(opt,callback){
???return this;
??????? ?}
?})
})(jQuery);
?
(function($){
?$.fn.plusin = function(opt,callback){
??return this;
?}
})(jQuery);
請問這兩種方式有什么區別
就這種情況而言,是沒有區別。
當然extend有多個重載。
http://news.cnblogs.com/group/topic/2640/