silversurfer5150 — 2011-04-02T17:09:11-04:00 — #1
I have an onclick handler which executes and jquery ajax load function but I need to validate a form first before executing the load function. I don't know how to prevent the load from occurring until the validate is complete. I am validating using the jquery validate plugin. Any ideas?
paul_wilkins — 2011-04-02T18:34:14-04:00 — #2
The jQuery validate documentation page has a section called "Plugin Methods". At the top of that list of methods is one called "validate( options )" that you can click on to get more details.
The "validate( options )" page has two tabbed sections, called Overview and Options.
In the Options tab is one called submitHandler which shows some code to achieve what looks to be precisely what you need.
silversurfer5150 — 2011-04-03T09:00:09-04:00 — #3
Thanks for pointing me in the right direction, got it sorted :). I have been working on an opencart mod.
The fact that a bit cms system like opencart relies on ajax for its checkout funcion showed me that a lot of people aren't considering users with js disabled nowadays and I have always learnt that I should take this into consideration.
I can see that you're a very experienced js developer, what do you think?
paul_wilkins — 2011-04-03T09:06:06-04:00 — #4
silversurfer5150 — 2011-04-03T10:31:15-04:00 — #5
Thanks I really appreciate the advice.
BTW how do you debug your scripts? I have been using firebug and console.log() to dump variables but I would like to learn how to trace through properly, I have tried the Venkman debugger and can't seem to get it to work. Do you know of any good tutorials on tracing though with either Venkman or firebug or anything similar?
paul_wilkins — 2011-04-03T21:37:53-04:00 — #6
I debug them using the built-in debugger that comes with Google Chrome.
Script Panel - FirebugWiki
A tutorial on using it is at:
Typically I breakpoint at a certain place, then use the step commands to walk on through the execution to help narrow down the cause.
felgall — 2011-04-03T22:37:26-04:00 — #7
That one is just about identical in how it works to the Venkmann extension for Firefox (and also as similar to the ones built into Safari, IE8, and Opera).
About the only difference between them all is where you find the option to open them.
silversurfer5150 — 2011-04-04T08:37:10-04:00 — #8
Thanks for the advice both,