While it's not the most performant (assign a class to the elements that's unique to each grid if you need higher performance), thought I'd share the function I use to help select elements relative to a specific grid:
function selectGridElements($grid, selector){
// Select only the elements that are part of this grid (exclude elements that are in nested grids)
var depth = $grid.children().first().parents(".pq-grid").length;
return $grid.find(selector).filter(function(){
return $(this).parents(".pq-grid").length == depth;
});
}
Usage:
$thisGridButtons = selectGridElements($grid,'button.my_button_class');
or:
selectGridElements($grid,'button.hello_world').click(function(){alert('Hello world')});