I explained the problem below this code
<div id='content'> <div id='help'> blah blah blah once there lived a king named midas blah blah blah </div> <script> $(document).ready(function() { $('#help').click( function () { $('help').hide(500); }) }) </script> </div> <script> function ondelete() { </script>
Inside the div there is a piece of content that has โcontentโ as its identifier. Inside, I have a div. What is display: none bydefault, and if the user clicks the help button, I do
$('#help').show(500);
and when the user clicks the same help button or the user clicks inside the div, then I do this code to hide this div $ ('# help'). hide (500)
This works well until I make an ajax request to update the content div id = 'content' I am rewriting the same help topic with the same content. this is how I rewrite the entire content area except the header and footer.
but after updating it with the response text, the click event at the top of the code that is inside the .ready document does not work when onclick is working on this div
I mean, it works well. without it, when clicking and with this document code prepared above, it does not work when overwriting from ajax.
From my experience, javascript code or links do not work when code with script tags src and script is dynamically loaded and updated using ajax.
Now I use onclick instead of this document, ready to hide and show the help div.
and above all
when there is a overwrite from ajax if you again set $(#'help').click = .... code this works. like function ondelete() { document.getElementById('content').innerHTML = xmlHTTP.responseText $('#help').click (function() { $('#help').hide(500); }); }
so you need to update all attached events when you update it using ajax.
Please post your comments and suggestions to overcome this.
javascript jquery
Jayapal chandran
source share