The struts 2 jQuery plugin has a built in publish
/subscribe
framework.
If you define your own publish and subscribe event (for example on a grid) the subscribed function will be called every time the event is published. For details please see (Struts 2 jQuery Subscribe is called more than once)
To prevent this, there is a isSubscribed
method which can be used.
For a grid as:
<sjg:grid id="gridtable"
onBeforeTopics="before_grid_load" >
The JS will be:
$.subscribe('before_grid_load', function(event, data) {
if ( $('#gridtable').isSubscribed('before_grid_load') ){
return ;
}
//go on with function
}
The problem is that the $('#gridtable').isSubscribed('before_grid_load')
returns false
every time!
Check your lib to your jsp
Enable jQuery Grid Plugin in your Head Tag
The function
isSubscribed
is applied on the element$('#gridtable')
but subscribed to the$(document)
. I have tested with the last element and it didn't work to me. But tried with the first element and it worked.Script:
For grid: