How to pass ids dynamically to a method that uses JQuery
Hi ,
I am using an Ajax enabled version of display tag.
I have attached war file for your reference .
It is running wonderfully when I create a single grid , but when I have more one grid inside a jsp , I am facing the problem.
Here the main thing is the usage of a js file named displayTagAjax.js , which uses JQuery in turn .
Here this file displayTagAjax.js has a two methods
changeLinks() and
changeUsingSelector() which are kind of hard coded .I am pointing where the hard coding is :
1.In side changeLinks() method the line ..
-
selector = 'table#[b]dispTable[/b]>thead>tr>th>a';
as it takes the table id
'dispTable' as hard coded.
2.In side the method changeUsingSelector() the line ..
-
newStr = "JavaScript:doAjax('"+action+"','"+qryStr+"',[b]'ajxDspId'[/b]);";
Here the div id
'ajxDspId' is hard coded .
Now the actual code snippet which uses the js file is like the following (you can also check the index.jsp inside the war file )
-
<script language='javascript' src="js/jquery.js" type="text/javascript"></script>
<script src="js/displayTagAjax.js">
</script>
<!--- display tag -->
<div id="ajxDspId">
<display:table name="sessionScope.result" pagesize="10" htmlId="dispTable" sort="list">
<display:column property="id" title="ID" />
<display:column property="name" sortable="true"/>
<display:column property="email" sortable="true"/>
<display:column property="status" />
</display:table>
</div>
Now the main problem is as the
dispTable and
ajxDspId both are hard coded in side the js files ,I can not create more than one grid in a single .
Irrespective of how many grids I create in jsp , the two methods in side the displayTagAjax.js file will always work on the specific table id (i.e. htmlId="dispTable" ) and div id .
As I do not have any way to pass this two values from the jsp to the js methods , I am being able make this functions work properly for multiple grids .
Can some body help me to make this two methods generic ?
The forum is not allowing me upload the war file may be the size is big .
Please have look at the link for war download .
http://code.google.com/p/displaytagajaxed/downloads/list
Regards,
Ayan