kendo-labs / knockout-kendo

A project to create a robust set of Knockout.js bindings for the Kendo UI widgets.
http://kendo-labs.github.com/knockout-kendo/
273 stars 144 forks source link

Parent widget cannot be resolved #175

Open dkrmer88 opened 9 years ago

dkrmer88 commented 9 years ago
if (widgetConfig.parent) {
    var parent = $element.closest("[data-bind*='" + widgetConfig.parent + ":']");
    widget = parent.length ? parent.data(widgetConfig.parent) : null;
}

knockout-kendo.js -- line 172

If bindings are applied by a custom binding or programmatically the selector doesn't work. In my case this would be okay but probably not for other controls.

var parent = $element.parent();
dkrmer88 commented 9 years ago

My simple solution so far (which might be too simple):

if (widgetConfig.parent) {
    while(widget == null) {
        $element = $element.parent();
        widget = $element.length ? $element.data(widgetConfig.parent) : null;
    }
}