Inside jQuery.html(), I want to execute the following script.
$("#row1").html("<td id="cellId"><script>if (selectedStr) {var elem = $(\"#cellId\");
$(elem).bind(\"onRefresh\", function() {loadColor(selectedStr); storeStr(selectedStr);});$(elem).trigger(\"onRefresh\");) }</script><td>")
Requirement:
I had a testPage.jsp which contains table with cells. When a particular cell is selected and "submit" button is clicked, a popup opens. In the popup page, some data is changed and is processed through ajax. The resultant ajax response has to be dynamically set to the parent row. The ajax response builds the whole content that is to be set.This is where I fail.
The Ajax response will be something like this.
<td>.....<td>
<td>.....<td>
<td>content<script>...</script></td>
<td>.....<td>
<td>content<script>...</script></td>
...
Moreover the "selectedStr" is a javascript global variable in testPage.jsp.
Problems: 1. "selectedStr is undefined" is the browser error msg. I couldn't get reference to the global variable. 2. The element binding is not happening.
I tried to make use of jQuery.getScript(), jQuery.globalEval, jQuery.eval. I couldn't understand the {{html}} of JQuery.
Thanks!
"cellId"