Referencing/Selecting Dynamic DOM
Hi guys, not sure if my subject is completely correct, but basically here's my problem.
I'm passing in HTML code and dynamic data from a database, from a model, through an Ajax call, to a single DIV in my view.
Example from the model:
- $loadModuleStr = '';
- $loadAdminStr .= '<td><a href="#" id="updatePrivs" set="No" user="' . $users[0] . '" module="' . $users[1] . '">Yes</a></td>';
- $loadAdmin['loadUsers'] = $loadAdminStr;
Example from the ajax call:
- $("#importedUsers").html(json.loadUsers);
And the view:
- <div id="importedUsers"></div>
The data is in JSON format and comes in very nicely and displays the way I want. What I want to do now is reference/select that <a href="#" id="updatePrivs" like this:
- $("#updatePrivs").bind("click", function(event) {
- //set some vars and make another ajax call to do some more work...
- }
But for some reason I can't and I'm thinking that the HTML code I push in is not actually part of the DOM.
I need to dynamically enter a number of rows, so the entire "importedUsers" DIV has to be dynamically built.
Is there another way to do this, or some way to grab "updatePrivs" when it's clicked, when building it the way I've done above?
Thanks!
David