Well you are now making your form processing somewhat asynchronous, at
least to the degree that your submit event handler function will return
before the actual form validation starts. Fixing this should would
probably look like this:
-----------------------------------------------------------------------------------------------------------
// when submitting the form, check the values to make sure they are numeric
$("#lePlanForm").submit(function() {
var retval;
// Give the user a processing message
$.blockUI();
var form = jQuery(form).unbind('submit')[0];
var callbackClosure = arguments.callee;
return setTimeout(function()
{
retval = checkForm();
// Undo the processing message
$.unblockUI();
if (retval==true)
{
form.submit();
}
else
{
form.bind('submit', callbackClosure);
}
}, 10);
return false;
});
-----------------------------------------------------------------------------------------------------------
The basic idea is to always cancel the form submition per default. Then
when the now semi-asynchronous checkForm function has finished we decide
if we still want to submit the form or if validation has failed. Also
note that you have to unbind the 'submit' event before manually
submitting the form after validation as this would probably cause an
endless loop.
Let me know if this works,
-- Felix
--------------------------
http://www.thinkingphp.org
http://www.fg-webdesign.de
RCS Computers wrote:
Felix,
Thank you, that did indeed give blockUI enough time to bring up the
message. However, it created another problem.
// when submitting the form, check the values to make sure they
are numeric
$("#lePlanForm").submit(function() {
var retval;
// Give the user a processing message
$.blockUI();
return setTimeout(function()
{
*retval = checkForm();*
// Undo the processing message
$.unblockUI();
}, 10);
return retval;
});
Notice that I use the return value of checkForm to stop submission of
the form if there are invalid values. Using the timeout function
seems to break this as the form is always being submitted. How do I
get the results of retval back from the setTimeout() function?
Thanks.
--------------------------------------
Randy Syring
RCS Computers & Web Solutions
502-644-4776
http://www.rcs-comp.com
"Whether, then, you eat or drink or
whatever you do, do all to the glory
of God." 1 Cor 10:31
Felix Geisendörfer wrote:
I've just looked at this real quick, but would something like this
maybe work:
----------------------------------------
|$.blockUI(messageElement); |
setTimeout(function()
{
| retval = checkForm();
|| $.unblockUI(); |
|}, 100);
|----------------------------------------
|
|It should give blockUI some time to come up before the current
thread get's pinned.
-- Felix Geisendörfer aka the_undefined
--------------------------
http://www.thinkingphp.org
http://www.fg-webdesign.de
Mike Alsup wrote:
That's a problem. I see what you're doing, and I understand why
you're doing it, but I don't know of any way to force the browser to
render changes while you've got the current thread pinned. You really
need async behavior to make this work, but that's not an option for
you in your use case.
I don't have an answer for this. Anyone have any ideas?
Mike
On 2/21/07, RCS Computers <[EMAIL PROTECTED]> wrote:
Basically, I have some CPU intensive form validation that takes about 3
seconds to complete. I would like blockUI to start before the form
processing and stop after the form processing. However, the blockUI message
doesn't ever show up. When I comment out $.unblockUI(), the blockUI message
shows up AFTER the form processing is completed. Code can be found here (57
lines):
http://sh.nu/p/9301
I can arrange for the full HTML and JS if needed.
--
--------------------------------------
Randy Syring
RCS Computers & Web Solutions
502-644-4776
http://www.rcs-comp.com
"Whether, then, you eat or drink or
whatever you do, do all to the glory
of God." 1 Cor 10:31
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
------------------------------------------------------------------------
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
------------------------------------------------------------------------
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/