0

I'm trying to to bind values from jquery mobile slider using knockout components. But I failed to do that. Is there any solution yo it, except custom bindings? My js-code:

 ko.components.register('slider', {

            viewModel: {

                createViewModel: function (componentInfo) {
                    $(componentInfo.element).slider("refresh");

                }

            },

            template: { element : 'netval'}

        });

        var viewModel = function (value) {
            var self = this;
            self.value = ko.observable(value);
            self.id = ko.observable("slider-new");
            self.min = ko.observable(10);
            self.max = ko.observable(100);
        };
        var Model = new viewModel(50);
        ko.applyBindings(Model);

My fiddle

  • You do want a custom binding handler. You also want to pass `value` as the component's `params` (the `componentInfo` you're getting has no `element` property). Your `createViewModel` should return a viewmodel. – Roy J Oct 20 '16 at 15:53
  • See http://stackoverflow.com/questions/12856112/using-knockout-js-with-jquery-ui-sliders – Dan Beaulieu Oct 20 '16 at 18:14

0 Answers0