views:

129

answers:

0

I'm using the asmselect plugin to allow users to select & order multiple items from a select box.

I only want to enable the submit button when the user has made a change. The following works, but change does not get called when sorting the selected elements:

<script type="text/javascript">
  $(document).ready(function() {
    $("select[multiple]").asmSelect({
      addItemTarget: 'bottom',
      highlight: false,
      hideWhenAdded: true,
      sortable: true
    });
    // track changes with our own event
    $("#mySelect").change(function(e, data) {
      $("#submit").removeAttr("disabled");

      // if it's a sort or an add, then give it a little color animation to highlight it
      if (data.type != 'drop') data.item.animate({ 'backgroundColor': '#ffffcc' }, 20, linear', function() {
        data.item.animate({ 'backgroundColor': '#dddddd' }, 500);
    });
  });
}); 
</script>

The select & submit:

<select id="mySelect" multiple="multiple" name="mySelect[]" title="Select Elements">
  <% foreach (var item in Model)
     { %>
  <option <%= item.Selected ? "selected=selected" : "" %> value="<%= Html.Encode(item.ID) %>">
    <%= Html.Encode(item.Text) %></option>
  <% } %>
</select>
<input type="submit" value="Save" id="submit" disabled="disabled"  />

How can I enable the submit when selected elements are sorted?