RIRedinPA Posted May 10, 2010 Share Posted May 10, 2010 if I am loading content into a div using the get feature of jquery, and that content has some clickable objects in it will jquery recognize those as well? What I am doing is building a site that tracks bugs on our software. The site pulls the bugs from a mysql db and displays in a table format. There's an edit link which passes the record id number of that bug (via ajax) to a php file, where a form is filled in with the bug data and passed back, a hidden div is then shown with the form in it. Part of the code I pass back has a submit button and a close button (css styled anchors) and I'm using the same process on them as I am on the edit link but not getting any results. My script looks like this: <script src="js/jquery.js"></script> <script language="javascript"> $(document).ready(function(){ //hide edit form $('#editform').hide(); //toggle bug description $("a.clickable").click(function(){ if ($('#' + $(this).attr('opendesc') + '_bottom').is(':visible')) { //alert($(this).attr('opendesc')); $('#' + $(this).attr('opendesc') + '_bottom').hide('slow'); } else { $('#' + $(this).attr('opendesc') + '_bottom').show('slow'); } }); //close bug description $("a.btnClose").click(function(){ //alert($(this).attr('closedesc')); $('#' + $(this).attr('closedesc')).hide('slow'); }); //close edit window -- not working $("a.btnCloseEdit").click(function(){ alert("you are here!"); $('#editform').hide(); }); //use ajax to load edit bug form $("a.edit").click(function(){ //get item id var itemid = $(this).attr('itemid'); //load edit form data $.get('lib/editform.php', {thisid: itemid}, function(data) { $('#editform').html(data); //alert('Load was performed.'); }); //show edit form $('#editform').show('show'); }); $("a.btnCloseEdit").click(function() { alert("k"); }); }); </script> the last click function, where I'm just posting an alert, binds back to this code, which is on the page being loaded in the ajax call: //other code <a href=\"javascript:void(0);\" class=\"submitform\">Submit</a></form><p><a href=\"javascript:void(0);\" class=\"btnCloseEdit\">X</a> //other code I'm a noob with jquery and not sure how it works. Does it sneak peek the page after it loads and get all the objects into some sort of array? I'm thinking it is doing that and because I am adding other object through AJAX it is not seeing those, since the page is not being reloaded. Am I missing something here? Thanks Quote Link to comment Share on other sites More sharing options...
RIRedinPA Posted May 11, 2010 Author Share Posted May 11, 2010 I got a response from another forum. Just an FYI for those interested that is what is happening. Since I am loading objects after the initial load jquery is not seeing them. A poster on the other site told me to use the .live() call. http://api.jquery.com/live/ I worked around it by just calling another function with a onmousedown(); handler and then dropping the jquery scripts in there. Probably not the correct way to do it but I'm going to punt on this for now since I need to get this project wrapped up. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.