thecodeholic / lobipanel

jQuery plugin for bootstrap panels. It extends panels with several common and useful functions.
MIT License
168 stars 75 forks source link

Panel positions after sorting #15

Closed andrius-senulis closed 8 years ago

andrius-senulis commented 8 years ago

Hi!

It's a really cool feature with being able to sort the panel by dragging. However, is there a functionality to get the positions of the panels after dragging?

Cheers, Andrius

thecodeholic commented 8 years ago

Hi, This can be achieved using jquery. After panel is dragged, you need to find all .lobipanel elements in its parent and get index for each of them

$('selector')
.on('dragged.lobiPanel', function(){
    var $parent = $(this).parent(),
           $children = $parent.children();
    $children.each(function(ind, el){
        console.log(el, $(el).index());
    });
})
.lobiPanel();

I have not tested this code. I have just written it. But it should print element and its new position in console

andrius-senulis commented 8 years ago

Thank you, as you suggested, I've solved it retrieving them with jQuery on the dragged.lobiPanel event.

thecodeholic commented 8 years ago

Welcome!!!