From 82a0b850cb734933c32fc305a2802187acdc2b47 Mon Sep 17 00:00:00 2001 From: robjames Date: Tue, 21 May 2013 16:31:51 +0200 Subject: [PATCH] Allow for updating options I $observe the attrs for changes and update the options. This enables you to update the options on the fly. Example being enabling and disabling the ability to sort, during an "edit" action. --- src/sortable.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sortable.js b/src/sortable.js index 7c39e53..409aa65 100644 --- a/src/sortable.js +++ b/src/sortable.js @@ -8,9 +8,11 @@ angular.module('ui.sortable', []).value('uiSortableConfig',{}).directive('uiSort return { require: '?ngModel', link: function(scope, element, attrs, ngModel) { - var onReceive, onRemove, onStart, onStop, onUpdate, opts; + var onReceive, onRemove, onStart, onStop, onUpdate, opts = {}; - opts = angular.extend({}, uiSortableConfig, scope.$eval(attrs.uiSortable)); + attrs.$observe('ui-sortable', function(){ + opts = angular.extend({}, uiSortableConfig, scope.$eval(attrs.uiSortable)); + }); if (ngModel) {