开发者

Preventing conflict between jquery prototype/plugin methods

Suppose i have a main js file on the website that contains some code as follows:

$.fn.extend({
  break: function(){
    //code here
  },
  cut: function(){
   //code here
  },
  // ...many other methods
});

and i 开发者_开发百科use it like so:

$('#mydiv').break().animate() ...

Now if i add an external jquery plugin file that also has a 'break' method, how do i prevent conflict between my $.fn methods and someone else's?


You can't.

This is why many plugins, such as jQuery UI, only add a single method to the prototype which takes an action name as a parameter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜