A template for a jQuery plugin with options and accessible methods?

前端 未结 4 992
名媛妹妹
名媛妹妹 2021-02-10 05:57

I am want to build a plugin with accessible methods and options, this for a complex plugin. I need the methods to be accessible outside the plugin because if somebody ads someth

4条回答
  •  情话喂你
    2021-02-10 06:36

    Have you tried the jQuery UI Widget Factory?

    There was a bit of a learning curve, but I love it now, handle the options, and defaults and allows methods, keeps everything wrapped up tight very fancy :)


    EDIT

    The jQuery UI Widget Factory is a separate component of the jQuery UI Library that provides an easy, object oriented way to create stateful jQuery plugins.

    – Introduction to Stateful Plugins and the Widget Factory.

    I don't think the extra overhead is much to be worried about in most circumstances. These days I write in coffescript and everything is compiled, minified and gzipped, so a few extra lines here and there doesn't make much of a difference. My research in website speed seems to indicate that the number of HTTP requests is a big deal - indeed the former colleague that put me on this track worked for a browser based game and was all about speed speed speed.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题