jquery widget, _create or _init

Gelin Luo picture Gelin Luo · Oct 21, 2010 · Viewed 11.1k times · Source

Some jquery plugin extend widget use _create method, while others use _init method, can someone explain the differences between the two?

Also any guidance on when it is better to extend widget or directly extend jquery.fn?

Answer

Mottie picture Mottie · Oct 21, 2010

From the jQuery UI Developer Guide:

Once the element is created, all other calls to the widget name where the first parameter is not a string will call the _init() method; if options are passed, the .option() method will be called before the _init() method