I am using livequery for my project for attaching events in links in table/grid. The grid is paginated ajax calls.
The confirmable link shows up a dialog when clicked. This click event is attached to the grid using livequery.
Below is a mockup of the grid/table structure. The #ajaxGrid part is returned as HTML in the pagination ajax call.
<div id="ajaxgridDiv">
<div id="ajaxGrid">
<a href="#" class="confirmableLink">Click here for a Jquery UI dialog</a>
<div class="paginator">
//links to prev/next pages.
</div>
</div>
</div>
How can use .live() or .delegate() instead of livequery in such a situation. My problem arises from the fact that I cannot attach a 'load' event using delegate as such an event is not bubbled up.
The only solution I could come up with was :
to return a script snippet along with the ajaxGrid HTML like
<script type="text/javascript">
$(function(){
$('ajaxGrid').trigger('ajaxGridLoadEvent');
});
</script>
and configure delegation in the main page as:
<script type="text/javascript">
$(function(){
$('ajaxGridDiv').delegate('#ajaxGrid','ajaxGridLoadEvent',function(){
//attach click events to the confirmableLinks
});
});
</script>