I'm using jquery 1.5.1. By switching from jquery-ui 1.8 to jquery-ui 1.9, I noticed that inheritance is not working anymore. I encountered the following problem :
I create a widget tpDialog which inherits from the dialog widget
$.widget( "ui.tpDialog", $.ui.dialog, { ... });
and a tpParmDialog widget which inherits from tpDialog
$.widget( "ui.tpParmDialog", $.ui.tpDialog, { ... });
In tpDialog, there is a callback on a button which set the resizable option :
$('.tp-dialog').tpDialog('option', 'resizable', true);
When invoking this function, the $.widget.bridge function in jquery.ui.widget.js is called, which contains :
var instance = $.data(this, name);
where name = 'tpDialog'.
This invokes the data function in jquery.js. At the end of this function, thisCache[ name ] is returned.
In case of tpDialog, thisCache has a member tpDialog, so no problem.
However in case of tpParmDialog, which contains also this button, name is 'tpDialog', but thisCache contains a tpParmDialog member but no tpDialog member, so undefined is returned. In the button callback, it should be transparent whether the dialog is a tpDialog or tpParmDialog instance., so calling
$('.tp-dialog').tpParmDialog('option', 'resizable', true);
is not an option.
This was working with jquery-ui 1.8.
Is there another or better way to implement inheritance with jquery-ui 1.9, or another way to set options ?
I create a widget tpDialog which inherits from the dialog widget
$.widget( "ui.tpDialog", $.ui.dialog, { ... });
and a tpParmDialog widget which inherits from tpDialog
$.widget( "ui.tpParmDialog", $.ui.tpDialog, { ... });
In tpDialog, there is a callback on a button which set the resizable option :
$('.tp-dialog').tpDialog('option', 'resizable', true);
When invoking this function, the $.widget.bridge function in jquery.ui.widget.js is called, which contains :
var instance = $.data(this, name);
where name = 'tpDialog'.
This invokes the data function in jquery.js. At the end of this function, thisCache[ name ] is returned.
In case of tpDialog, thisCache has a member tpDialog, so no problem.
However in case of tpParmDialog, which contains also this button, name is 'tpDialog', but thisCache contains a tpParmDialog member but no tpDialog member, so undefined is returned. In the button callback, it should be transparent whether the dialog is a tpDialog or tpParmDialog instance., so calling
$('.tp-dialog').tpParmDialog('option', 'resizable', true);
is not an option.
This was working with jquery-ui 1.8.
Is there another or better way to implement inheritance with jquery-ui 1.9, or another way to set options ?
Status
Need more info
- No status
- Need more info
- Answered
- Working on it
1 user has this question

