I had an odd downside the place a easy jQuery expression labored as soon as solely on an ASP.NET web page. It turned out that .NET UpdateProgress controls on the identical web page had been inflicting issues with partial web page refreshing from AJAX calls.
I had the best of jQuery code on a person management:
$(doc).prepared(operate () );
First time in, the web page displayed and the whole lot appeared good. In reality, I went a while earlier than I realised that when the web page was partially refreshed by an auto-postback from a dropdown management my button now not labored.
On additional investigation of the dad or mum web page, I discovered that my person management was sitting in a.NET UpdateProgress management part. The UpdateProgress gives a easy technique of making use of partial web page refreshes; it is a magical factor when it really works however I’ve had hassle with them earlier than, interfering with different javascript (together with ASP.NET AJAX controls) on the identical web page.
The options can generally be fairly concerned, however on this specific downside I learn of a easy answer.
The issue lies with the truth that the jQuery prepared(operate() solely runs as soon as when the web page first begins. When the web page is partially refreshed (as in an AJAX name) we have to successfully re-wire the jQuery occasions.
All.NET programmes will know the operate PageLoad occasion very effectively, however there may be an equal javascript occasion too. We are able to use this to reload our jQuery occasions every time the web page is refreshed. Our code now turns into:
operate pageLoad() $(operate () );
That fastened it for me! The downside is the hit that we’ve got to load all of the jQuery every time the web page refreshes or partially refreshes as an alternative of simply as soon as. It wasn’t a lot of an issue for me on this case.
Notice that as we’re not checking the DOM is totally loaded (as when utilizing (doc).prepared), you must add the code to the underside of the web page and after the scriptmanager has been loaded.
I fear when I’ve to begin bodging javascript code as a result of it may be troublesome to check and debug. I’ve seen on the net that there are different extra refined fixes to this downside which leads me to suppose that this isn’t a definitive answer for all issues, so watch out. In the event you hear of a greater method of doing this, let me know.