Using jQueryUI factory widget to expand dialog

I am using the jqueryUI factory widget to extend the jqUI dialog widget. I installed the simplest widget that I can think of. He does nothing, just inherits the dialogue. However, I could not get it to work.

I have a fiddle demonstrating this here: View Fiddle

Here's the test markup:

<div id="a">hello</div> <div id="b">bye</div> 

Here's the javascript:

 (function ($, undefined) { var o = //Widget prototype { options: {}, _create: function () {}, destroy: function () { $.Widget.prototype.destroy.call(this); }, _setOption: function (key, value) { $.Widget.prototype._setOption.apply(this, arguments); }, }; //Run jQuery widget factory to create the widget $.widget('cs.csDialog', $.ui.dialog, o); } (jQuery)); //Test it out $("#a").dialog(); //Works $("#b").csDialog(); //Fails 

Inside jqUI, the following error appears: this.uiDialog undefined

I do not see what I did wrong. I would really appreciate any help. Thanks.

+4
source share
2 answers

The reason it doesn't work, as I wrote in my comment, is because you have overwritten the _create function.

+3
source

Just for future readers, here's how to call the basic _create function, as pointed out in the comments. Answered William Niu , answering another question.

  _create: function() { $.ui.dialog.prototype._create.call(this); } 

Another way to invoke the _create base is to add the following line of code to your method:

 this._super(); 
0
source

All Articles