Unobtrusive-jQuery-UI
Unobtrusive-jQuery-UI copied to clipboard
cannot call methods on [widget name] prior to initialization; attempted to call method 'destroy'
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).
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');
}
Thank you, Steven!