使用jquery-chosen-sortable https://github.com/mrhenry/jquery-chosen-sortable 但如果提交两次,则正确的顺序。
<form method="post" id="f1">
<div id="container">
<h2>Selected and Disabled Support</h2>
<div class="side-by-side clearfix">
<p>Chosen automatically highlights selected options and removes disabled options.</p>
<div>
<em>Multiple Select</em>
<select data-placeholder="Your Favorite Types of Bear" style="width:350px;" multiple class="chosen chzn-sortable" id="test_me" name="nl_item[attributes][link][]" tabindex="8">
<option value=""></option>
<option>American Black Bear</option>
<option>Asiatic Black Bear</option>
<option>Brown Bear</option>
<option>Giant Panda</option>
<option selected>Polar Bear</option>
<option selected>Sloth Bear</option>
<option disabled>Sun Bear</option>
<option disabled>Spectacled Bear</option>
</select>
</div>
<button type="submit">submit</button>
</div>
</div>
</form>
<script>
$( "form#f1" ).on( "submit", function () {
var str = $( "form#f1" ).serialize();
console.log( str );// <---
return false;
} );
</script>