Search and Top Navigation
#7489 closed bug (notabug)
Opened June 18, 2011 11:08PM UTC
Closed June 19, 2011 12:53AM UTC
Last modified June 19, 2011 04:23AM UTC
autocomplete fails when new widget 'jqn.menu' is created
Reported by: | kccarter | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.9.0 |
Component: | ui.autocomplete | Version: | 1.8.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
the issue is when a menu widget is created in a different namespace ie: 'jqn.menu' the menu property of the autocomplete control no longer has access to the methods defined in 'ui.menu' the menu object is now referencing 'jqn.menu'.
this issue was observed in version 1.8.1. based on the look I have taken at version 1.8.13, I believe the issue is still present there as well.
Attachments (0)
Change History (3)
Changed June 19, 2011 12:53AM UTC by comment:1
description: | the issue is when a menu widget is created in a different namespace ie: 'jqn.menu' the menu property of the autocomplete control no longer has access to the methods defined in 'ui.menu' the menu object is no referencing 'jqn.menu'. \ \ this issue was observed in version 1.8.1. based on the look I have taken at version 1.8.13, I believe the issue is still present there as well. → the issue is when a menu widget is created in a different namespace ie: 'jqn.menu' the menu property of the autocomplete control no longer has access to the methods defined in 'ui.menu' the menu object is now referencing 'jqn.menu'. \ \ this issue was observed in version 1.8.1. based on the look I have taken at version 1.8.13, I believe the issue is still present there as well. |
---|---|
resolution: | → invalid |
status: | new → closed |
Changed June 19, 2011 01:04AM UTC by comment:2
Even though I believe this is as-designed today, it's something I think we should consider fixing in a future major release. I've added a comment to that effect on the Widget factory wiki page: http://wiki.jqueryui.com/Widget-factory#commentnum1308445289 . Feel free to follow up there.
Changed June 19, 2011 04:23AM UTC by comment:3
I was thinking about this problem and I think I came up with a reasonable solution. this could would reside in the jquery.ui.widget.js file right after the var _remove line.
$.fn.extend({
widget: function (name, options) {
var parts = String(name).split('.'), namespace = parts[0], name = parts[1], _widget = $[namespace][name];
/* when calling into a namespace in order to set the /*this*/ variable we have to instanciate a new instance of the widget. could we pass a reference to the widgets prototype? if we did does it risk corruption of that widget's class?*/
if ($.isFunction(_widget)) {
_widget.call(new _widget(), options, this);
/*_widget.call(_widget.prototype, options, this);*/
}
return this;
}
});
This is as designed. The autocomplete widget depends on ui.menu via $.fn.menu. That way you can provide your own $.fn.menu and it will depend on it instead of the one that lives at $.ui.menu. If you want your own menu that doesn't fill that role, give it a different alias in the $.fn. namespace with $.widget.bridge and then use bridge to restore the $.fn.menu -> $.ui.menu alias:
This assumes you load autocomplete (which includes ui.menu) first, then jqn.menu. If you load jqn.menu before autocomplete then only the first line above should be needed. If you have additional questions about this, please ask on the forum http://forum.jquery.com/using-jquery-ui
For more on the widget bridge, see http://www.erichynds.com/jquery/using-jquery-ui-widget-factory-bridge/