Welcome Guest, Not a member yet? Register   Sign In
jquery only works once then page needs refreshing
#1

[eluser]prestondocks[/eluser]
Hi, hoping that someone can answer this question that is causing me a headache.

I have just started to use Jquery to impliment AJAX updates on my web page.

I have a table with a list of meeting minutes each row has an option to delete. I have coded this to work with jquery. So the user clicks the delete button, jquery uses .get() to send the request to my controller which deletes the meeting minute. It then loads the meeting_minutes.php partial view with the true option and returns the code to the ajax function which replaces the content of the div holder for the meeting mintues.

The problem is that the next time I click the delete link it ignores the ajax function. I have to refresh the page to get the delete to work again.

Any ideas what I need to do?

Thanks
Simon
#2

[eluser]prestondocks[/eluser]
OK, just found the "A" solution, but it's not a nice one. I have had to reinclude references to the jquery library and my jscript file in every view partial. It seems that when jquery updates the div with new html. The links don't know about the jquery that was originally loaded in the header of the main page.

Is there another way of getting the new code inserted by jquery to see the original jquery?
#3

[eluser]Dennis Rasmussen[/eluser]
Use jQuery.live()

http://api.jquery.com/live/
#4

[eluser]shelton_dev_guy[/eluser]
What's happening is the stuff you add in the div doesn't get added to the DOM tree




Theme © iAndrew 2016 - Forum software by © MyBB