jQuery-UI 1.8的改变

近日,升级jquery-ui至最新的1.8版本,结果运行异常,样式不正确。

反复调试,才发现jquery-ui 1.8较之1.7.2改变甚多。

特抄录如下:

Core

[ edit ]

Widget Factory

[ edit ]

Widget prototype changes
  • Moved $.widget.prototype to $.Widget.prototype so it can fully use prototypal inheritance ($.Widget is a constructor)
  • Renamed _init() to _create()
  • A new _init() method was added to perform "default functionality"
  • _init() is called every time the plugin is called without passing the name of a method to invoke
  • Renamed _setData() to _setOption()
  • Removed _getData() since it should never be overridden
  • Removed bindings for data events, must always use the option method now
  • Added widget() to return the main/outermost element of the widget
  • Getter methods no longer need to be explicitly defined. Any method that returns a value other than undefined or the plugin instance is automatically treated as a getter. This also adds the ability to define a method that can act as a chainable setter and a getter.
  • destroy() now removes all widget-namespaced events bound to this.element and this.widget()
  • option() with no parameters now returns the full options hash
  • Instantiating a widget directly via the new keyword now fully initializes the widget (no need to call the initialization method after the constructor)
[ edit ]

Properties moved from $.ui.foo to $.ui.foo.prototype
  • $.ui.foo.defaults -> $.ui.foo.prototype.options
  • $.ui.foo.eventPrefix -> $.ui.foo.prototype.widgetEventPrefix
[ edit ]

Other changes
  • $.widget now accepts a base widget to extend as the second parameter, defaults to $.Widget
  • added $.widget.bridge to allow creation of stateful plugins using a custom constructor
  • calling the constructor method multiple times now performs an action. If a hash is passed to the constructor, that hash is passed to the option method. The _init() function is called.
[ edit ]

New Widget Method
  • A new common method has been added, called widget . This method will return the .ui-{pluginname} element. Depending on the plugin, in many cases this is different than the original element, otherwise it will return the original element.

    For example, when you call $("#myDiv").dialog() the #myDiv element gets the .ui-dialog-content class while a generated wrapper element gets the .ui-dialog class . Before the widget method existed it was a bit of a pain to call $("#myDiv").closest(".ui-dialog") and though that worked in this case, for many plugins that doesn't work, for example, Datepicker, or Autocomplete, where the widget element is not a wrapper.

    Now with the widget method, you can simply call $("#myDiv").dialog("widget") to get the widget element.

[ edit ]

Example code

An example for migrating a custom widget from 1.7 to 1.8.

[ edit ]

Interactions

[ edit ]

Draggable

  • removed ui.absolutePosition in callbacks (3990 )
  • Changed stack option to accept a selector instead of a hash (4375 )
[ edit ]

Droppable

  • removed ui.absolutePosition in callbacks (3989 )
[ edit ]

Widgets

[ edit ]

Accordion

  • Removed alwaysOpen option in favor of collapsible option (4030 )
[ edit ]

Datepicker

  • The yearRange option now allows different formats for each half of the range, e.g. '1950:-18'. This means that relative years must always use a '+' or '-' to indicate their status. In particular, to reference the current year you must use '+0', e.g. '-10:+0'.
  • To suppress show/hide animations set showAnim to blank or false instead of setting duration to 0.
  • Manually entered dates now update the alternate field.
  • Default tab processing is no longer suppressed.
[ edit ]

Dialog

  • beforeclose option changed to beforeClose - beforeclose is now deprecated and will be removed in the next release
  • Dialog buttons now use the new Button widget, it has to be included to get properly themed dialog buttons. If it is missing, plain unthemed buttons will be used, which will still work, just not look as nice.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值