I think I mixed something up in here but can't seem to figure out what it is. I tried using firebugs console to view the values but they looked correct to me.
Code:
function down (arrow){
var numOrders = $('div[id^=order_]').size();
if (arrow == numOrders) {
return;
}
var id_name = "#order_" + arrow;
var math_move = arrow + 1;
var inverse_id_name = "#order_" + math_move;
$(id_name).animate({"top": "+=30px"}, "slow");
$(inverse_id_name).animate({"top": "-=30px"}, "slow");
var new_id = id_name.replace("#", "");
var new_id2 = inverse_id_name.replace("#", "");
$(id_name).attr('id',new_id + "delay");
$(inverse_id_name).attr('id',new_id2);
$("#"+ new_id + "delay").attr('id',new_id);
}
function up (arrow){
var numOrders = $('div[id^=order_]').size();
var check = arrow - 1;
if (check <= numOrders) {
return;
}
var id_name = "#order_" + arrow;
var math_move = arrow - 1;
var inverse_id_name = "#order_" + math_move;
$(id_name).animate({"top": "-=30px"}, "slow");
$(inverse_id_name).animate({"top": "+=30px"}, "slow");
var new_id = id_name.replace("#", "");
var new_id2 = inverse_id_name.replace("#", "");
$(id_name).attr('id',new_id + "delay");
$(inverse_id_name).attr('id',new_id2);
$("#"+ new_id + "delay").attr('id',new_id);
}
The buttons code is
Code:
<p class="author_up"><a href="javascript:move();" onclick="up(arrow=1); return false;"><img src="arrow_up.jpg" alt="up" /></a></p>
<p class="author_down"><a href="javascript:move();" onclick="down(arrow=1); return false;"><img src="arrow_down.jpg" alt="down" /></a></p>
The are generated dynamically as well as the content being moved. Thanks for any ideas you can offer.
Bookmarks