[英]call function after jquery selectable is done
在 jquery selectable 完成正在執行的操作(排序或其他)之后,我無法找到一種調用函數的方法。 我需要找出什么時候完成移動東西,因為它接縫我無法訪問某些元素。 這是代碼:
我想調用這個函數來修復 zIndex 數字.. reparaZindex() 我試圖把它放在開始或更新中,但沒有任何作用。
$(function() {
$( ".sortable" ).disableSelection();
$( ".sortable" ).sortable({
start: function(event, ui) {},
update: function (event, ui) {}
});
});
我的腳本工作正常,加載頁面時我可以檢查所有 id-s,但更改列表后不起作用。 這是一個鏈接,可以查看:
(我已經在上面的例子中停止了 reparaZindex,但它不起作用)
試試這段代碼:
$(function() {
$( ".sortable" ).disableSelection();
$( ".sortable" ).sortable({
stop : function(event, ui){
reparaZindex();
alert("bananas eat children");
}
});
});
如果您收到警報但您的功能不起作用,則意味着您的 reparaZindex() 做錯了。
$(function()
{
$( ".sortable" ).disableSelection();
$( ".sortable" ).sortable({
start: function(event, ui) {
var start_pos = ui.item.index();
ui.item.data('start_pos', start_pos);
},
update: function (event, ui) {
var start_pos = ui.item.data('start_pos');
var end_pos = ui.item.index();
var eroare=0;
//incepe trimiterea la bd a indexurilor
for(var i=0;i<ui.item.parent().children().length;i++){
if(1==0) //eroare
eroare=1;
var x =ui.item.parent().children()[i];
//$(x).find('img').css('z-index',500-i);
y=$(x).children()[0];
y.style.zIndex=500-i*2;
if($(x).children().length>1){
c=$(x).children()[1];
TEMP=500-i*2+1;
c.style.zIndex=TEMP;
//alert(TEMP);
//alert($(x).children()[1].id)
}
}
if(eroare==0)//daca bd a upatat indexurile pt start_pos la eng pos
{
var copii=ui.item.parent().children();
for(var i=0;i<ui.item.parent().children().length;i++){
//alert(ui.item.parent().children().eq(i).id())
}
}
else {
}
},
stop: function(event, ui) { $.each($(".sortable > li"), function() {alert("!!!"+$(this).attr("id"));}); }
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.