2011-11-03 21 views
-2

好吧,所以我正在嘗試集成jQuery UI插件可選(網格),並且我喜歡它如何發佈選定的索引。這是我想做些什麼:如何在jQuery UI中添加li元素的id可選倍數

$(function() { 
    $("#selectable").selectable({ 
     stop: function() { 
      var result = $("#select-result").empty(); 
      $(".ui-selected").each(function() { 
       var index = $("#selectable li").attr('id'); 
            // But I want the ids of all the selected elements, 
            // but the id of the first is just getting copied on my site! 
       result.append("#" + (index + 1)); 
      }); 
     } 
    }); 
}); 

回答

0

嘗試:

$(function() { 
    $("#selectable").selectable({ 
     stop: function() { 
      var result = $("#select-result").empty(); 
      $(".ui-selected").each(function() { 
       var index = $(this).attr('id'); 
       result.append("#" + (index + 1)); 
      }); 
     } 
    }); 
}); 
+0

完美! ,任何想法如何我可以將選定的值傳遞給$ .post請求? –

+0

'$(「#selectable」).serialize()'你只需要將它傳遞給$ .post – samura

+0

,但我試圖提醒他們srceen,並在那裏重新調整空白? –

相關問題