Where to put the default destroy in the jQuery UI 1.8.1 widget's destroy function

Posted by dominicminicoopers on Stack Overflow See other posts from Stack Overflow or by dominicminicoopers
Published on 2010-04-27T18:04:26Z Indexed on 2010/04/28 0:03 UTC
Read the original article Hit count: 428

Filed under:
|
|

Ok, I'm having a slight bit of confusion writing my own jQuery UI widget plugins. The problem lies in the destroy function. In the docs, it says to put the default destroy first then write other things particular to the widget after it.

$.Widget.prototype.destroy.apply(this, arguments); // default destroy
// now do other stuff particular to this widget

See http://jqueryui.com/docs/Developer_Guide

However in their example scripts (those being the actual pluings for jQuery Ui released code, does it the opposite. The

$.Widget.prototype.destroy.apply(this, arguments);

is at the end of the function. See http://dev.jqueryui.com/browser/trunk/ui/jquery.ui.progressbar.js (and all of the other built in widgets as well)

So which is it? The way the current widgets are written, or by the explanation in the code comment in the Developer_Guide?

© Stack Overflow or respective owner

Related posts about jquery-ui

Related posts about jQuery