I have a simple page with two lists. Using jQuery I have set the two lists as sortable and connected them together so I can add and remove from the list. This all works well.
I have come to the part of the feature where I need to save the results into the data store. When the user clicks on a submit button, there is an asynchronous request to an MVC controller that accepts a collection of strings.
I have two ideas on how to handle this scenario.
Idea one, remove all existing elements and re-create based on what is in the collection.
Idea two, loop through the list and add or update the sort order based on if a record already exists.
What this best way to do this and it there an option I have missed?
I’m using asp.net MVC with jQuery but this shouldn’t matter.
Either method should work for your request. The dumping and recreating “should” be less resource intensive than the insert and update method in idea two.