Dynamically generated jqgrid, to attach a handler?

Hello. My grids are created by php, i.e. after the call to the database I write
echo "<table id="table_".$row[ID].""></table>";

Everything is fine, data arrives and is displayed in how they can be harmonized correctly, but now I can't use different methods in this grid. Ie If I did
$("#table_273").setGridParam ({url:new_url});
$("#table_273").trigger("reloadGrid");


Everything worked fine when I just hard prescribed the creation of table's. Now that swears, says that the object has no method setGridParam. I think you need to use something like bind, but do not know how. Tried:
$("#table_273").jqgrid("setGridParam",{'url':new_url});
$("#table_273").trigger("reloadGrid");


The effect is the same, only now the object has no method jqgrid. What could be the problem?
October 3rd 19 at 02:51
1 answer
October 3rd 19 at 02:53
Solution
Perhaps you have a typo, but:
You do echo "
";
Identifiers will be table273 and the like, and not table_273
Well, we must not forget $("#table_273").jqgrid("setGridParam",{'url':new_url}); — here, too, the identifier should be substituted dynamically.
Or, for example, by class and not by id to cling to.
No, that's fine. I checked the code generated on the page, everything is true - Earline40 commented on October 3rd 19 at 02:56
99% sure that console.log($('#table_273').length) will give 0
If you just in the console type $('#table_273'), the table will show?
Again, make sure that 273 not sehardcore, and that this id is in the database... - Delpha_Cummin commented on October 3rd 19 at 02:59
I checked it, all right. Maybe it's the fact that the grids themselves are also created dynamically and the browser "knows" that #table_273 is a grid, and works with him as a regular table? - Earline40 commented on October 3rd 19 at 03:02
Browser that the creation of PHP, just static HTML absolutely equivalent.
Again a typo, but: $("#table_273").jqgrid("setGridParam",{'url':new_url}); — it should jqGrid, those with a large letter G - Delpha_Cummin commented on October 3rd 19 at 03:05
Thank you! The problem was in this! - Earline40 commented on October 3rd 19 at 03:08

Find more questions by tags JavaScript