gvas / knockout-jqueryui

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

Make tabs binding behave when tabs are nested inside a bound widget #15

Closed kylechandler closed 10 years ago

kylechandler commented 10 years ago

Fiddle that demonstrates the problem: http://jsfiddle.net/kylechandler/9dQ48/ Fiddle that points to the new version of tabs.js: http://jsfiddle.net/kylechandler/EcTsX/

gvas commented 10 years ago

Cool, thanks!

Is the extra check inside the tabsactivate event's handler necessary?

$(element).on('tabsactivate.ko', function (ev, ui) {
    //Prevent this from bubbling up to any parent tab widgets
    ev.stopPropagation();
    if ($(element)[0] === ev.target) {
        //Only activate if this is the right tab widget. Is there a better way to check this?
        value.active(ui.newTab.index());
    }
});

Isn't ev.stopPropagation() enough?

$(element).on('tabsactivate.ko', function (ev, ui) {
    //Prevent this from bubbling up to any parent tab widgets
    ev.stopPropagation();
    value.active(ui.newTab.index());
});
gvas commented 10 years ago

Merged. Thanks!