views:

132

answers:

1

hi,

can we call javascript function from g:paginate tag .
I need to call a javascript function when clicked on next page/number .

I'm using like this but no luck :
g:paginate next="Forward" prev="Back" max="100" maxsteps="15" controller="Links"
action="list" total="${Links.count()}" onclick="return show_waiting();"/>


function show_waiting(){
alert('11111111111');
return true;
}

This is not working . Can any one help me on this ?

thanks.

+1  A: 

You cannot directly add a javascript method to the <g:paginate> tag. Seems logical since the <g:paginate> will render many html links.

The best way to achieve what you need is to write a javascript that will listen any 'onclick' events on elements.

For instance if you code is :

<div class="paginateButtons">
  <g:paginate .../>
</div>

Then using jQuery, you can add:

<g:javascript>
  $(function(){
    $(".paginateButtons a").click(function() {
      alert('11111111111');
    });
  }
</g:javascript>
fabien7474
thanks fabien, your solution working good. I accepted your answer :-)
srinath