0

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
frictionlesspulley
  • 11,070
  • 14
  • 66
  • 115

1 Answers1

0

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>
frictionlesspulley
  • 11,070
  • 14
  • 66
  • 115