Thanks to visit codestin.com
Credit goes to github.com

Skip to content

knockout.js dynamic add #81

@jxmiller

Description

@jxmiller

Using knockout.js in a repeating element. When I add an object to the view model, it adds a row to a table where a slider is supposed to render. The error I get in chrome is: "Calling context element does not have instance of Slider bound to it. Check your code to make sure the JQuery object returned from the call to the slider() initializer is calling the method".

I have tried to destroy and recreate but no luck. Here is my binding handler where the error occurs.
ko.bindingHandlers.sliderValue = {
init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var value = valueAccessor();
$(element).slider('destroy');
$(element).slider({});
$(element).slider('setValue', value())
$(element).on('slide', function (ev) {
value(ev.value);
});
},
update: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var value = valueAccessor();
$(element).slider('setValue', value());
}
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions