【发布时间】:2011-05-06 12:09:23
【问题描述】:
我的网站上有一个可排序面板 (jQuery UI),但需要将每列中的元素数量限制为最多 12 个。
我尝试了一些方法,但似乎无法正常工作。我需要查看“i”是否为 12 或更大,如果是,请不要更新,但我似乎做不到!
任何人有任何建议或可以正确地推动我吗?
下面是jQuery!
function updateWidgetData(){
var items=[];
$('.column').each(function(){
var columnId=$(this).attr('id');
$('.dragbox', this).each(function(i){
var collapsed=0;
if($(this).find('.dragbox-content').css('display')=="none")
collapsed=1;
var item={
id: $(this).attr('ID'),
collapsed: collapsed,
order : i,
column: columnId
};
items.push(item);
});
});
var sortorder={ items: items };
//Pass sortorder variable to server using ajax to save state
$.post('includes/updatePanels.php', 'data='+$.toJSON(sortorder), function(response){
if(response=="success")
$("#console").html('<div class="success">Your preferences have been saved</div>').hide().fadeIn(1000);
setTimeout(function(){
$('#console').fadeOut(1000);
}, 2000);
});
}
【问题讨论】:
-
我在我的答案中添加了可排序的内容,这就是实际问题。 :)
标签: jquery-ui