I created two custom JQuery UI widgets with same name but with different namespaces as given below:
First widget:
$.widget('finance.dialog',{....}); // this was created in the file jquery.finance.dialog.js
Second widget:
$.widget('hr.dialog',{.....}); // this was created in the file jquery.hr.dialog.js
Apart from these two, JQuery UI has its own dialog widget (ui.dialog) in the namespace ui.
My question is:
Which dialog widget will be called when i call the following in a web page as given below?
$('div#something').dialog();
Please note I include all the three widget variants in the web page.
I understand there are conflicts in the above scenario. How can we invoke a widget function with its namespace so that there will not be any conflicts?
I had the same question, but I don’t think it’s possible to invoke a jquery ui widget with the namespace.
If I understand correctly from this: http://bugs.jqueryui.com/ticket/7489
By defining widgets with the same name, it’s by design to overwrite earlier definitions. Because regardless of namespace, the widgets are mapped with their name to $.fn.
As suggested in the bug ticket you can use the bridge function to create a unique mapping to the specific namespaced widget and call it using the unique name.
In your case, it can be like this:
I suppose another way would be to create unique widget names in the first place.