Writing jQuery Plugins Using Classes and Prototypes

后端 未结 3 1636
时光取名叫无心
时光取名叫无心 2021-01-30 09:44

Is it good or bad practise writing plugins this way(using class and prototypes), what are disadvatages of this code?

function PluginName(jqueryObject, options) {         


        
3条回答
  •  [愿得一人]
    2021-01-30 10:22

    The easiest way to write jQuery plugins (especially if they have some internal state) is to use jQuery UI Widget Factory.

    I wouldn't recommend to reinvent the wheel and write lots of boilerplate code by yourself.

    https://learn.jquery.com/jquery-ui/widget-factory/why-use-the-widget-factory/ https://learn.jquery.com/plugins/stateful-plugins-with-widget-factory/

提交回复
热议问题