Created
September 10, 2011 18:58
-
-
Save courtsimas/1208648 to your computer and use it in GitHub Desktop.
a little sortable magic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("ul#sidebar_whatever").sortable({ | |
placeholder: "ui-state-highlight", | |
update: function(event, ui) { //this is where we'll do some updating crap | |
$("ul#sidebar_whatever").find('li.widget').each(function(){ | |
var val = $(this).find('input.hidden_cool_input').val();// this val will be like "124,1" | |
var result = val.split(','); | |
var order = $("ul#sidebar_whatever li.widget").index($(this))//getting the order of the current element in the loop | |
result[1] = order; // we're reassigning the order | |
$(this).find('input.hidden_cool_input').val(result.toString());//we're putting the values back in, as "124,0" or "125,3" or whatever. | |
}) | |
} | |
}); | |
/*class ".ui-state-highlight" is a class that will highlight where you are supposed to drag the small widget.*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment