Unbinding events for 1.8 plugins in 1.9

Unbinding events for 1.8 plugins in 1.9

In widget factory 1.8 i used to bind event like this:

this.element.on("click." + this.widgetName, $.proxy(this._doStuff, this));

Which got automatically unbound when calling the destroy method.

Now in widget factory 1.9 there is a eventNamespace variable which seems to be the widgetName + some number.

this._on($element, { click: this._doStuff });

Is essentially the same as:

this.element.on("click." + this.eventNamespace, $.proxy(this._doStuff, this));

In the destroy method jQuery UI1.9 event are unbound like this:

this.element.unbind( this.eventNamespace ) ;

Which results in 1.8 plugins not properly getting destroyed.

To clarify, when i bind an event handler the 'old' way, $element.on("click.myPlugin", $.proxy(this._doStuff, this));
The new widget factory will unbind like this.element.unbind("myPlugin1") ;