7

The simple code below describes my question (at least I hopse so):

$.widget("ui.mydialog", $.ui.dialog, {
  _create: function() {
    // How to call _create method of dialog?
  }
});

I tried to call $.ui.dialog.prototype._create() from within the above create method, but get the below error in Firebug:

this.element is undefined
this.originalTitle = this.element.attr('title');
jquery...5667348 (line 5864)

How else can I call that "super" method?

jQuery UI version 1.8.8

medihack
  • 16,045
  • 21
  • 90
  • 134

1 Answers1

12

I guess I just found a solution ... $.ui.dialog.prototype._create.call(this);

The full code:

$.widget("ui.ajaxdialog", $.ui.dialog, {
  _create: function() {
    // Your code before calling the overridden method.
    $.ui.dialog.prototype._create.call(this);
    // Your code after calling the overridden method.
  }
});
medihack
  • 16,045
  • 21
  • 90
  • 134
  • 6
    For jqueryui 1.9x you can simply do: `this._super('_create');` the above solution is also still valid. – earcam Jul 20 '12 at 13:24
  • 2
    Interesting. Simple `this._super()` in `_create` function will also do. Then it is the matter of taste probably. – Saulius Dec 04 '12 at 12:24
  • 1
    Actually, according to the docs (http://api.jqueryui.com/jQuery.widget/#method-_super), _super doesn't have any arguments. It just magically knows where you are. – Grinn Dec 11 '12 at 15:34
  • Every time you call any of the "overridable" function "this._super" is changed to function, which knows about which "super" it actually refers to. – Konstantin May 10 '13 at 11:37