I can't figure a way to call a function after jquery selectable is done doing what is doing (sort or whatever). I need to find out when is done moving things because it seams I can not acces some elements. Here is the code:
i want to call this function to repair the zIndex numbers.. reparaZindex() I tryed to put it in the start, or update, but nothing works.
$(function() {
$( ".sortable" ).disableSelection();
$( ".sortable" ).sortable({
start: function(event, ui) {},
update: function (event, ui) {}
});
});
My script works ok, when the page is loaded I can check all the id-s, but after changing the list is not working. Here is a link to see:
(i've put the reparaZindex in stop in the example of above, but is not working )
Try this bit of code:
$(function() {
$( ".sortable" ).disableSelection();
$( ".sortable" ).sortable({
stop : function(event, ui){
reparaZindex();
alert("bananas eat children");
}
});
});
If you get the alert but your function doesn't work, that means your reparaZindex() is doing something wrong.
$(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"));}); }
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.