Last post Aug 12, 2009 11:40 AM by dotnethacker
Jun 25, 2009 09:08 PM|JamesDalton|LINK
view would be
The form is initially loaded using jQuery and the masks work. When the partial view is updated after the post, the ready function doesn't get executed. If I create an OnComplete handler and update the page using jQuery it works. Not sure if I'm doing something
wrong or if it is a bug/feature of MVC Ajax.
Jun 26, 2009 01:35 AM|lvzhq|LINK
Pls check your IIS version, if iis version is low some jquery function is invalid
Jun 26, 2009 12:25 PM|JamesDalton|LINK
This is happening running from VS2008. jQuery behaves as I would expect it's MVC that is acting strange.
Jun 26, 2009 02:02 PM|paul.vencill|LINK
there's at least three other posts about this recently... It's simple; the 'ready' function fires only on the initial page load, when elements are ready, but before images are done downloading. It simply doesn't (and isn't designed to) fire after an
ajax post. That's what oncomplete handlers are for, as you've discovered.
Jun 26, 2009 03:32 PM|JamesDalton|LINK
From what I've read about the ready function, if the document isn't ready the function gets queued and executed later. If the document is ready the function is executed immediately. The problem isn't just with the ready function. If I let MVC handle everything,
even a simple alert doesn't get executed. If I place the code below in the OnComplete handler, my code executes (including the ready function.)
MVC do all the work. Most of them used jQuery to either do all of the work or at least update the DOM.
Jun 26, 2009 04:26 PM|Haacked|LINK
When you update the DOM with new HTML, the browser doesn't automatically execute scripts in the new bit of HTML. Our Ajax helpers would need to parse the partial HTML and try and execute the scripts, which is tricky and something we don't currently do.
One approach you could take is to look at jQuery live events.
Jun 29, 2009 01:18 PM|JamesDalton|LINK
That explains the difference. I have a couple of ideas on how to handle it, your jQuery live events suggestion being one of them, but I have another question about MVC, forms and posting that'll I'll post seperately.
Aug 12, 2009 11:40 AM|dotnethacker|LINK
Thanks, I have been having problems with this issue described here as well and will take a look at using JQuery to execute any scripts.