Ticket #3633 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

init callback problem with ui widget factory

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

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

Change History

comment:1 Changed 5 years ago by scott.gonzalez

  • Owner set to scott.gonzalez
  • Priority changed from minor to critical
  • Status changed from new to accepted
  • Milestone changed from TBD to 1.next

comment:2 Changed 5 years ago by scott.gonzalez

  • Status changed from accepted to closed
  • Resolution set to fixed
  • Milestone changed from 1.next to 1.6

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.

Note: See TracTickets for help on using tickets.