2010-02-26 3 views
1

asmselect 플러그인을 사용하여 사용자가 &을 선택 상자에서 여러 항목을 주문할 수있게했습니다.jquery asmselect : 변경시 발생하지 않는 변경

사용자가 변경 한 경우에만 제출 버튼을 사용 가능하게하려고합니다.

<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> 

셀렉트 & 제출 :

<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" /> 

가 어떻게 요소가 정렬을 선택하면 제출 사용할 수 있습니다 선택한 요소를 정렬 할 때 작품에 따라,하지만 변화가 호출되지 않습니다?

function makeSortable() 
{ 
    // make any items in the selected list sortable 
    // requires jQuery UI sortables, draggables, droppables 

    $ol.sortable({ 
     items: 'li.' + options.listItemClass, 
     handle: '.' + options.listItemLabelClass, 
     axis: 'y', 
     update: function(e, data) 
     { 
      var updatedOptionId; 

      $(this).children("li").each(function(n) 
      { 
       //$option = $('#' + $(this).attr('rel')); 
       // i'm not sure what this is here for as the return will break ordering 
       //if($(this).is(".ui-sortable-helper")) 
       { 
       // updatedOptionId = $option.attr('id'); 
       // return; 
       // 
       } 

       //$original.append($option); 
       $original.append($('#' + $(this).attr('rel'))); 
      }); 

      //we want to trigger change event always, even if it is only the order that has been changed. 
     //if(updatedOptionId) triggerOriginalChange(updatedOptionId, 'sort'); 
      triggerOriginalChange(updatedOptionId, 'sort'); 
     } 
    }).addClass(options.listSortableClass); 
} 

답변

1

당신은 다음과 ASM 기능을 변경해야합니다. 그것

내 업데이트 된 버전의 asmselect보십시오. See code and example here

+0

주석 처리 된 코드를 삭제하십시오. –

0

JQuery와/JQuery와 - UI의 이전 버전, 추가 이벤트가 UI-정렬 도우미 속성 항목에 대한 트리거 된 것 같다 :

+0

이 링크가 질문에 대답 할 수 있지만 여기에 답의 핵심 부분을 포함하고 참조 용 링크를 제공하는 것이 좋습니다. 링크 된 페이지가 변경되면 링크 전용 답변이 유효하지 않게 될 수 있습니다. –

관련 문제