asp.net mvc - jquery sortable, get list order -


What is the return to some rank in a sequence using jquery? Essentially, what I want to do, what thousands of people are doing (and I have searched well on the StoxHowflowflow) and updated the database in a serial manner.

Each item in the database has a "status" property - initially set to 0. Ul populated and pulled out, and I want to update the route controller back and store their position in the list.

I am using ASP.NET MVC / C # as my code base - but I am having trouble finding complete examples of this.

Ah! I understood it. I am posting it to everyone here.

  $ ("ul # unorderedListIdGoesHere li"). Index (ui.item); & Lt;% @ Control Language = "C #" Inherits = "System.Web.Mvc.ViewUserControl & lt; IEnumerable & lt; Model. Size & gt; & gt;" & Gt%; & Lt; Ul id = "section" & gt; & Lt;% foreach (Miscellaneous items in the model) {%> & Lt; Li class = "ui-state-default" id = "& lt;% = item.id%>" & Gt; & Lt; Span class = "ui-icon ui-icon-arrowthick-2-n-s" & gt; & Lt; / Span & gt; & Lt;% = Html.Encode (item.Name)% & gt; & Lt; / Li & gt; & Lt;%}% & gt; & Lt; / Ul & gt; & Lt; Script type = "text / javascript" & gt; $ {Document} .ready (function () {$ ("# section"). Sortable ({update: function (event, ui) {$ ("ul # section li"). Each (function () {var position = $ ("Ul # section li") index (this); var section = $ (this) .attr ("id"); $ .post ("/ section / status", {status: position, section: section}) ;})}}). DisableSelection ();}); & Lt; / Script & gt; & Lt; Style type = "text / css" & gt; #sections {list-style-type: none; Margin: 0; Padding: 0; Width: 60%; } # Section li {margin: 0 3px 3px 3px; Padding: 0.4 AM; Padding-left: 1.5 AM; Font size: 1.4em; Height: 18px; } #sections li span {status: complete; Margin-left: -1.3em; } & Lt; / Style & gt;  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -