I have a bunch of connected ul
lists in my view which are using a jQuery UI: Sortable directive to facilitate drag and drop and reordering of the list items.
Changes I make via jQuery UI's drag and drop I apply to the $scope
using the $apply
function, this part works…
The issue I am running into now however is that on drop into some of these lists I provide a custom form that the user needs to fill out.
The user has the option to:
- fill out the form and continue which then does the
$apply
call to persists the data into the$scope
- click a cancel button which instead of calling the
$apply
to store info, should revert the last drag/drop interaction effectively 're-rendering' all my lists to reflect the data that is still in the$scope
at this stage (since the latest drag had not had any effect on it yet).
The effect of this "cancel" button is effectively reverting everything to the point before the user picked up the list item and dragged it into another list.
How can I force a 'refresh' or 're-render' of my ng-repeat
s so that they visually refresh and show the current $scope
data again?
$scope.apply()
from inside the jQuery based directive but it doesn't seem to force a reload/re-render of the existing data. Probably because Angular thinks everything is exactly the same, not knowing about me having done DOM manipulation without telling it about it. So what I really need is just a 'force refresh' type of call, where Angular regardless of$scope
state just forces a refresh of its rendered data. – Wynn$timeout( function(){ ...add removed item back to $scope here... });
The $scope manipulation you perform in the the $timeout function should cause a second render to happen. – Dalenedalenna