使用与所有 jQuery UI 小部件相同的抽象化来创建有状态的 jQuery 插件。 如需了解更多有关部件库(Widget Factory)的细节,请查看 API 文档部件库(Widget Factory)。 默认功能 该演示展示了一个简单的使用部件库(jquery.ui.widget.js)创建的自定义的小部件。
jQuery UI 1.9 添加了重定义小部件的功能。因此,可以不用创建一个新的小部件,我们只需要传递 $.widget() 这样一个已有的小部件名称和构造函数即可。下面的实例在 open() 中添加了相同的记录,但不是通过创建一个新的小部件来完成的。$.widget( "ui.dialog", $.ui.dialog, { open: function() { console....
命名空间ui则是保留给官方 jQuery UI 插件的。 创建自己的插件的时候,应该使用自有的命名空间的, 这样可以让人一看就清楚这插件哪来的,是否是一个大体系的一部分。 Example 8.4. 给 widget 传递参数 $("") .appendTo( "body" ) .progressbar({ value: 20 }); 当我们调用jQuery.widget时,与创建标准插件的...
namespace: The location on the global jQuery object that the widget's prototype is stored on. For example a namespace of "ui" indicates that the widget's prototype is stored on $.ui. options: An object containing the options currently being used by the widget. On instantiation, any opti...
.removeData(this.widgetName );// 删除在create时保存的数据 有一个removeData的操作,那么下次调用$(XX).widgetName()就会重新实例化了。 需要注意的是,destroy方法在jquery.ui.widget.js中是有默认实现的,而_create和_init没有实现。因此如果用自己的方法覆盖destroy,不要忘记调用默认的: ...
ui-dialog-title: The container around the textual title of the dialog. ui-dialog-titlebar-close: The dialog's close button. ui-dialog-content: The container around the dialog's content. This is also the element the widget was instantiated with. ui-dialog-buttonpane: The pane that contains...
6. 注册 Widget 最后,我们需要将我们的 Widget 注册到 jQuery UI 中,使其可在页面中使用。下面是一个简单的示例: $.widget("custom.myWidget",MyWidget); 1. 在这个示例中,我们使用$.widget方法将 Widget 注册到 jQuery UI 中,名称为myWidget。
widget factory实现了一种单例模式,即不允许在同一个jQuery对象上多次实例化。 当调用$(XX).widgetName()进行初始化的时候,会执行以下代码(源码截取自jquery.ui.widget.js): $.widget = function( name, base, prototype ) { ... var instance = $.data( this, name ); // 从widget自身取出名字为name...
jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly interactive web applications or you just need to add a date picker to a form control, jQ
jQuery UI API - 对话框部件(Dialog Widget) 所属类别 小部件(Widgets) 用法 描述:在一个交互覆盖层中打开内容。 版本新增:1.0 对话框是一个悬浮窗口,包括一个标题栏和一个内容区域。对话框窗口可以移动,重新调整大小,默认情况下通过 'x' 图标关闭。 如果内容