Move Multiple Links In Controlgroup Up Or Down Using Jquery Mobile
This is a follow-up question on my previous question (Controlgroup: 3 buttons horizontal, multiple rows on JQuery Mobile) which was nicely answered. I now have multiple 'controls'
Solution 1:
You will need to use .nextAll(), .nextUntil(), .prevUntil(), .addBack(), .next(), .after(), .add() and .eq().
$(this).nextAll(".ui-last-child").eq(1)Check if there is a set of buttons after the current set.
$(this).prevUntil(".ui-last-child").addBack()Get all buttons in the same row of the down button and
.addBack()down button to jQuery collection object. Now we have three buttons.$(this).next(".ui-last-child")Next button. Now we have collected four buttons (all of them) but still we need to merge them into one object.
prevBtns.add(nextBtn)Merge all buttons into one object/variable.
moveAfter.after(setBtns)Move/append all buttons after the row below current set of buttons.
$("#layercontrol").on("click", ".down", function () {
var moveAfter = $(this).nextAll(".ui-last-child").eq(1);
if (moveAfter.length > 0) {
var prevBtns = $(this).prevUntil(".ui-last-child").addBack(),
nextBtn = $(this).next(".ui-last-child"),
setBtns = prevBtns.add(nextBtn);
moveAfter.after(setBtns);
}
});
Post a Comment for "Move Multiple Links In Controlgroup Up Or Down Using Jquery Mobile"