下面的简单代码描述了我的问题(至少我希望如此):
$.widget("ui.mydialog", $.ui.dialog, {
_create: function() {
// How to call _create method of dialog?
}
});
我试图从上面的创建方法中调用 $.ui.dialog.prototype._create()
,但在 Firebug 中出现以下错误:
this.element is undefined
this.originalTitle = this.element.attr('title');
jquery...5667348 (line 5864)
我还能如何称呼该“ super ”方法?
jQuery 用户界面版本 1.8.8
最佳答案
我想我刚刚找到了一个解决方案...... $.ui.dialog.prototype._create.call(this);
完整代码:
$.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.
}
});
关于javascript - 继承自 jQuery UI 对话框并调用覆盖的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4789493/