ducksboard / gridster.js

gridster.js is a jQuery plugin that makes building intuitive draggable layouts from elements spanning multiple columns
http://gridster.net/
MIT License
6.03k stars 1.2k forks source link

How to check if an element has a certain row and col value after dragging? #168

Closed anthonybarsotti closed 7 years ago

anthonybarsotti commented 11 years ago

I'm trying to check to see if a list item has been dragged to a certain row and col position and if it has I want to add a class to that list item. Has anyone tried this?

dustmoo commented 11 years ago

In each jquery wrapped widget has a coords() object that can tell you the row and col that it currently occupies:

$widget = $("#widget_id");
var col = $widget.coords().grid.col;
var row = $widget.coords().grid.row;

You can use those properties to determine the current col and row of a widget.