Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inherit from jQuery UI dialog and call overridden method

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

like image 835
Zardoz Avatar asked Jan 25 '11 02:01

Zardoz


1 Answers

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.
  }
});
like image 146
Zardoz Avatar answered Oct 07 '22 02:10

Zardoz