Browse Source

#664: .on('') -> scope.on('')

pull/699/head
RubaXa 9 years ago
parent
commit
e53002892f
  1. 34
      ng-sortable.js

34
ng-sortable.js

@ -126,7 +126,24 @@
scope.$apply(); scope.$apply();
} }
function _destroy() {
scope.off('$destroy', _destroy);
angular.forEach(watchers, function (/** Function */unwatch) {
unwatch();
});
sortable.destroy();
el[expando] = null;
el = null;
watchers = null;
sortable = null;
nextSibling = null;
}
// Initialization
sortable = Sortable.create(el, Object.keys(options).reduce(function (opts, name) { sortable = Sortable.create(el, Object.keys(options).reduce(function (opts, name) {
opts[name] = opts[name] || options[name]; opts[name] = opts[name] || options[name];
return opts; return opts;
@ -157,20 +174,7 @@
} }
})); }));
$el.on('$destroy', function () { // Create watchers for `options`
angular.forEach(watchers, function (/** Function */unwatch) {
unwatch();
});
sortable.destroy();
el[expando] = null;
el = null;
watchers = null;
sortable = null;
nextSibling = null;
});
angular.forEach([ angular.forEach([
'sort', 'disabled', 'draggable', 'handle', 'animation', 'group', 'ghostClass', 'filter', 'sort', 'disabled', 'draggable', 'handle', 'animation', 'group', 'ghostClass', 'filter',
'onStart', 'onEnd', 'onAdd', 'onUpdate', 'onRemove', 'onSort', 'onMove', 'onClone' 'onStart', 'onEnd', 'onAdd', 'onUpdate', 'onRemove', 'onSort', 'onMove', 'onClone'
@ -185,6 +189,8 @@
} }
})); }));
}); });
scope.on('$destroy', _destroy);
} }
}; };
}]); }]);

Loading…
Cancel
Save