Unobtrusive-jQuery-UI icon indicating copy to clipboard operation
Unobtrusive-jQuery-UI copied to clipboard

cannot call methods on [widget name] prior to initialization; attempted to call method 'destroy'

Open Daniel15 opened this issue 11 years ago • 2 comments

Thrown at this part of the script:

// call destroy to remove the ui widget
uiFn.call($el, 'destroy');

With custom widgets that use the widget factory. Accordion has this issue as well (and possibly other jQuery UI widgets).

Daniel15 avatar May 13 '13 06:05 Daniel15

This issue occurs as of version 1.9: http://jqueryui.com/upgrade-guide/1.9/#calling-an-invalid-method-now-throws-an-error

You can solve this by adding an if statement around the destroy method call:

// test if ui widget is initialized
if ($el.is('.ui-' + fn)) {
    // call destroy to remove the ui widget
    uiFn.call($el, 'destroy');
}

Nevets82 avatar May 22 '13 16:05 Nevets82

Thank you, Steven!

prokofyev avatar May 29 '13 08:05 prokofyev