Closed GoogleCodeExporter closed 8 years ago
I hacked in a solution for my project where I learned from your trigger-code
related to ASP.NET PageValidation and I added an override to
Sys.Mvc.AsyncForm.handleSubmit. It's not 100% (I still have to set the
watermarks again in Ajax.Form/OnSuccess and /OnFailure, but that may be
possible to fix?) but works for me.
This is what I added to my code:
$(document).ready(function () {
setWatermark(); // my function that sets the watermark for this form
var fn = window['Sys']['Mvc']['AsyncForm']['handleSubmit'];
if (typeof (fn) === "function") {
window['Sys']['Mvc']['AsyncForm']['handleSubmit'] = (function (origFn) {
return function () {
$.watermark.hideAll();
return origFn.apply(null, Array.prototype.slice.call(arguments));
};
})(fn);
}
});
Original comment by ha...@active.com
on 25 Jul 2010 at 10:37
Is there a globally-scoped function that is called, which triggers the
Sys.Mvc.AsyncForm.handleSubmit function call?
For example, in ASP.NET Web Forms, a call to __doPostback is made n the href of
the link/button, and that triggers everything.
If there is a similar function call in MVC, perhaps you could add the function
name to the triggerFns array near to top of the source file.
Also, if that's the case -- if there is such a function -- let me know and I
can see if it would be appropriate to add it permanently to the triggerFns list.
Original comment by t...@speednet.biz
on 27 Aug 2010 at 4:07
I'm not sure how I can figure that out, sorry. I put a breakpoint in the
handleSubmit but all I can see in the callstack is onsubmit, so I don't think
there is a global function like that. It seems they are wiring it up on each
form submit, but that's just my guess.
Original comment by ha...@active.com
on 27 Aug 2010 at 6:24
If you'd like, you can send me a demo page containing the problem and I'll take
a look to figure out what's being called.
Original comment by t...@speednet.biz
on 27 Aug 2010 at 6:40
Just to clarify the above: please send a LINK to a demo page.
Original comment by t...@speednet.biz
on 27 Aug 2010 at 6:41
http://abc123.is-a-geek.com
in the top-right box, click Logga in and the submit button there will do an
ajax request where it happens. This URL is only temporarily.
Original comment by ha...@active.com
on 27 Aug 2010 at 6:55
Thanks for the link. It looks like the issue is that the form tag is being
created with an "onsubmit" attribute, and that is why it is able to occur
before the watermark can intercept the submit event.
In MVC there should be a way to put a small piece of code in the form's
onsubmit attribute BEFORE the MVC code executes.
BEFORE:
<form action="..." onsubmit="Sys.Mvc.AsyncForm.handleSubmit(this, new
Sys.UI.DomEvent(event)...")
AFTER:
<form action="..."
onsubmit="$.watermark.hideAll();Sys.Mvc.AsyncForm.handleSubmit(this, new
Sys.UI.DomEvent(event)...")
I don't know of a way to intercept an onsubmit attribute placed in the HTML tag
before it executes, so I think the above method may be your best approach.
Original comment by t...@speednet.biz
on 28 Aug 2010 at 1:15
Re-ordering of statements in page solves the perceived problem.
Original comment by t...@speednet.biz
on 6 Sep 2010 at 12:10
ok, I'll give that a try, thanks!
Original comment by ha...@active.com
on 6 Sep 2010 at 7:11
Original issue reported on code.google.com by
ha...@active.com
on 25 Jul 2010 at 9:53