Skip to main content

Search and Top Navigation

#3633 closed bug (fixed)

Opened December 02, 2008 09:04AM UTC

Closed January 19, 2009 01:31AM UTC

init callback problem with ui widget factory

Reported by: timothee Owned by: scottgonzalez
Priority: critical Milestone: 1.7
Component: ui.core Version: 1.6rc2
Keywords: Cc:
Blocked by: Blocking:
Description

Currently if a callback option to a widget attempts to call a method of the widget itself AND the callback is fired from the _init method, the method call on the widget fails.

That is because:

1) in the widget factory, the _init method is ran from the constructor

2) the widget class instance is only added as dom data AFTER the constructor runs

in SVN ui.core.js, that's line 290:

(!instance && !isMethodCall &&

$.data(this, name, new $[namespace][name](this, options)));

A proposed solution is to:

1) remove the _init method call from the widget constructor

2) update line 290 to this:

(!instance && !isMethodCall &&

$.data(this, name, new $[namespace][name](this, options))._init());

Refer to this thread for other information:

http://groups.google.com/group/jquery-ui/browse_thread/thread/a478de0049994dd8

Attachments (0)
Change History (2)

Changed December 02, 2008 04:37PM UTC by scottgonzalez comment:1

milestone: TBD1.next
owner: → scott.gonzalez
priority: minorcritical
status: newaccepted

Changed January 19, 2009 01:31AM UTC by scottgonzalez comment:2

milestone: 1.next1.6
resolution: → fixed
status: acceptedclosed

Fixed in r1668. Thanks timothee.

It's worth noting that if you invoke callbacks during init, that you should be careful to make sure you already have any necessary properties and state setup to handle anything a user can do through the widget's API.