gvas / knockout-jqueryui

Knockout bindings for the jQuery UI widgets.
http://gvas.github.com/knockout-jqueryui/
MIT License
103 stars 38 forks source link

Add support for conflicting libraries #45

Closed Biohazord closed 9 years ago

Biohazord commented 9 years ago

In our project we use both Bootstrap and jQuery UI. Its a well known issue that button and tooltip conflict. In our project we use the widget factory bridge method to map the tooltip and button methods to another name.

$.widget.bridge('uibutton', $.ui.button);
$.widget.bridge('uitooltip', $.ui.tooltip);

This allows us to create a tooltip with the call $(element).uitooltip();

To get your binding to work we must make a change in the anonymous function that calls the binding factory for the tooltip. We must change the name of the binding from BindingHandler.call(this, 'tooltip'); to BindingHandler.call(this, 'uitooltip');

Its a minor change in the source code but it is a change. It would be nice to have a solution that works even when there are conflicts.

One possible solution: Create a widget bridge with a differently named function and store the new widget functions name. Instead of accessing the jQuery UI function like this $(element)[this.widgetName] use the bridged widgets function name. This would allow you to keep the binding as data-bind="{widgetName}: ..." yet avoid conflicts.

I'm working on a pull request but I'm not experienced with jQuery UI or this factory pattern you're using. It should at least give you an idea of what I'm going for.

gvas commented 9 years ago

Is this the same issue as #6 ? Does the solution described there work for you? I would rather not modify knockout-jqueryui if bootstrap's .noConflict() fixes these issues.

Biohazord commented 9 years ago

Yes this does work. I'm sorry I didn't try it before. I was under the impression that the Bootstrap noConflict method for tooltips was broken. It appears as thought that was fixed in the Bootstrap 3.0 release.