I have a web application written utilizing ASP.NET MVC. I have a page that refreshes content by updating, via AJAX, a DIV tag with the results of a partial view.
The partial view being generated contains HTML like this:
After the partial view has been updated a number of times, the click events stop working. The click events for other items on the page continues to work. And once the click events in the partial view stops working, even update the DIV tag with new content
doesn't clear the problem.
Does anyone have any explanation of what might be happening? Or of any possible solutions? Or even any suggestions of which I might search for?
You may narrow down this issue by splitting the ajax part. See if it is AJAX issue, or from other part of your code logic. If it's ajax, then try tools for example
F12 in chrome -> net panel, to watch ajax requests and responses see if it is a server error or other problems that prevents response to come back.
You can also see if there are javascript errors in Chrome's console panel.
richardr
Member
96 Points
107 Posts
Events not registing when displaying partial views via AJAX?
Feb 18, 2012 08:28 PM|LINK
I have a web application written utilizing ASP.NET MVC. I have a page that refreshes content by updating, via AJAX, a DIV tag with the results of a partial view.
The partial view being generated contains HTML like this:
<div class="itemName" style="" onclick="ItemClicked('2882');"> Item #1 - Blue Marbles </div> <div class="itemName" style="" onclick="ItemClicked('2011');"> Item #2 - Ceramic Bowl </div> <div class="itemName" style="" onclick="ItemClicked('2092');"> Item #3 - Evening Dress </div> <div class="itemName" style="" onclick="ItemClicked('2816');"> Item #4 - Fan </div>After the partial view has been updated a number of times, the click events stop working. The click events for other items on the page continues to work. And once the click events in the partial view stops working, even update the DIV tag with new content doesn't clear the problem.
Does anyone have any explanation of what might be happening? Or of any possible solutions? Or even any suggestions of which I might search for?
Richard
BU XI - MSFT
All-Star
22367 Points
2704 Posts
Microsoft
Re: Events not registing when displaying partial views via AJAX?
Feb 21, 2012 12:47 AM|LINK
Hello
You may narrow down this issue by splitting the ajax part. See if it is AJAX issue, or from other part of your code logic. If it's ajax, then try tools for example
F12 in chrome -> net panel, to watch ajax requests and responses see if it is a server error or other problems that prevents response to come back.
You can also see if there are javascript errors in Chrome's console panel.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework