Reputation: 367
I need one help On clicking on Li i am taking that at top its working fine you can see here
var theLis = lis.get(); // to be sorted
if (li.is(":animated")) return; // stop double clicks!
arrayMove(theLis, li.index(), 0);
In my application i have white background But whats happening while moving that li the background comes white as my app has white background. What i need is that when my li moves at top it should adjust the backgroung in this way.
$('li.method-item').click(function () {
var $this = $(this),
callback = function () {
$this.insertBefore($this.siblings(':eq(o)'));
};
$this.slideUp(500, callback).slideDown(500);
});
Note : But approach should be taken as the first link oi provided.
Thanks in Advance
Upvotes: 1
Views: 93
Reputation: 10155
here is one I put together
you might have to alter it to check if it is the first item that is clicked though.
$('li.method-item').click(function () {
var item = $(this);
var ul = item.parent();
item.css({
position: 'absolute',
top: item.position().top,
width: item.width()+'px',
background: '#fff'
});
item.animate(
{top: 0},
{speed: 200, complete: function(){
var itemclone = item.detach();
itemclone.css({position: 'relative', top: '0px', background: 'none'});
ul.prepend(itemclone);
}}
);
});
EDIT :
Use the one in the fiddle below
I have updated it to take make sure the clicked one is always on top and also to check if the first item is clicked.
Upvotes: 1