From 509bfafa4fb3a457e6e45d1892a22fb49191c051 Mon Sep 17 00:00:00 2001 From: Itai Bar-Haim Date: Mon, 10 Oct 2016 23:30:56 +0300 Subject: [PATCH 1/2] fixing the options doesn't update issue. --- knockout-sortable.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/knockout-sortable.js b/knockout-sortable.js index fedcff7..c91826d 100644 --- a/knockout-sortable.js +++ b/knockout-sortable.js @@ -95,6 +95,13 @@ // There seems to be some problems with updating the options of a sortable // Tested to change eventhandlers and the group options without any luck + var options = buildOptions(valueAccessor, sortableOptions); + var sortableElement = bindingContext.$data.SortableElement; + + for (var prop in options) { + sortableElement.option(prop, options[prop]); + } + return ko.bindingHandlers.template.update(element, valueAccessor, allBindings, viewModel, bindingContext); }, eventHandlers = (function (handlers) { From 840995313c437148bba12c2dd6475e239068325f Mon Sep 17 00:00:00 2001 From: Itai Bar-Haim Date: Tue, 11 Oct 2016 13:05:07 +0300 Subject: [PATCH 2/2] a better update method. --- knockout-sortable.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/knockout-sortable.js b/knockout-sortable.js index c91826d..3fc0e63 100644 --- a/knockout-sortable.js +++ b/knockout-sortable.js @@ -82,7 +82,7 @@ }.bind(undefined, e, viewModel, allBindings, options[e]); }); - var sortableElement = Sortable.create(element, options); + element._knockout_sortable = Sortable.create(element, options); // Destroy the sortable if knockout disposes the element it's connected to ko.utils.domNodeDisposal.addDisposeCallback(element, function () { @@ -96,12 +96,12 @@ // Tested to change eventhandlers and the group options without any luck var options = buildOptions(valueAccessor, sortableOptions); - var sortableElement = bindingContext.$data.SortableElement; + var sortable = element._knockout_sortable; for (var prop in options) { - sortableElement.option(prop, options[prop]); + sortable.option(prop, options[prop]); } - + return ko.bindingHandlers.template.update(element, valueAccessor, allBindings, viewModel, bindingContext); }, eventHandlers = (function (handlers) {