Cybercampbell
Cybercampbell

Reputation: 2606

Jquery Isotope Library move select to first position?

I am using jquery isotope on my site and I have a page where I has some links that when one is clicked it reoders the isotope items so the clicked link's associated div gets reorded to the first position. I can find any examples of this so i'm helping someone could lend a hand with this.

Thanks C

EDIT:

Here is what I have so far: jsfiddle

$('.button').click(function(){
  var sortName = $('#container .active');
  $('#container').isotope({ sortBy : sortName });
});

I've commented the JS pane with what i'm trying to do. This is not even close I don't think but I am trying. I think i'm going the wrong way about it. Maybe I should be using data-something="" instead.

Please let me know if you have any better ideas.

Also, I need to have them stay in their original positions (apart from the selected one obviously). so if 6 was selected it would be 6123457 or if 3 was selected it would be 3124567. The previous item selected would move back into it's original position.

Upvotes: 4

Views: 1333

Answers (1)

guessimtoolate
guessimtoolate

Reputation: 8642

I forked your fiddle. Check it out and see if it matches your expectations. Basically what I did was drop the notion of sorting those items, because if I read your intention right, you only needed to put one div in front of the other. I wasn't sure what's to happen with the other items when you do this rearrangement, so I left them in their last position.

Edit: I guess I misread the question or had not enough coffee that day. I've updated the fiddle to better match what you described.

Upvotes: 4

Related Questions