开发者

javascript in grails paginate

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 s开发者_JS百科how_waiting();"/>

function show_waiting(){

alert('11111111111');

return true;

}

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

thanks.


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜