MDA/MDD/TDD/DDD/DDDDDDD
posts - 536, comments - 111, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

jquery插件开发

Posted on 2008-05-08 13:19 leekiang 阅读(624) 评论(1)  编辑  收藏 所属分类: jquery(进去而已)
1,jquery插件开发模式
http://www.learningjquery.com/2007/10/a-plugin-development-pattern
There 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.html

3,传入回调函数的一种写法,不知可有更好的
   传参时的写法: callback:'test()'
   调用时的写法:
    if(options.callback) eval(options.callback);
  来源 http://www.heartstringz.net/blog/posts/view/jquery-countdown-plugin

4,(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/

评论

# re: jquery插件开发[未登录]  回复  更多评论   

2010-05-21 13:19 by 访客
穿参时应该可以这样写:
callback : test

test(){

}

只有注册用户登录后才能发表评论。


网站导航: