angular-ui / ui-sortable

jQuery UI Sortable for AngularJS
http://angular-ui.github.io/ui-sortable/
MIT License
1.26k stars 444 forks source link

html content or directive is reloaded after move #483

Closed goleafs closed 8 years ago

goleafs commented 8 years ago

Using ui-sortable and it's working well.

The issue I have is that the content of the html element that is moved, is an angular component (or directive). When the position is swapped, the component is re-initialized (recreated from scratch). Since this component is calling back end data, this is not ideal, and the user experience is pretty bad.

Is there a way to just move the dom element and not have angular re-initialize the component?

thgreasi commented 8 years ago

Yea, that's just how this directive works. It changes the model and let's ng-repeat do it's magic and emit the new HTML based on the model & the template. In the README though, you can check out the Static HTML Sorting example which might help you a bit.

thgreasi commented 8 years ago

Not setting ng-modelmight do the trick.

thgreasi commented 8 years ago

But obviously, in case that you care about storing the new model order, using a caching layer for your service sound as the most appropriate way for an implementation.