Form Submit JS

Status
Not open for further replies.

PtrNrs

Member
Having perused the documents readme.html and Form Javascript Objects, I'm still having trouble working out how to fire JS events on form submission.

I have created the custom JS file components/com_fabrik/js/X.js and can successfully call functions from that file. So far so good.

However, I inserted a variation on the following function (ie just the alert) and couldn't get it working . . .

Fabrik.addEvent('fabrik.form.submit.start', function(form, event, button) {
alert('aha! you really should not press that button');
form.result = false;
})

Is there something else I need to do? Is there a bug? Do I need to upgrade from GitHub?

I'm using a GitHub release from approx 4 weeks ago. As this is on-line, I'm reluctant to upgrade to the latest, but will if I need to.
 
Hmmm, that should work.

Do you get any JS errors on form load, specifically puking up about object Fabrik not existing?

In 3.0 sometimes we've had issues with the form's JS getting fired before the main Fabrik object is ready.

-- hugh
 
None of that sort of error.

I've attached both the JS file and the JS errors I receive.

Is there any way I can track the problem through?
 

Attachments

  • 5.js.txt
    3.2 KB · Views: 338
  • 2013-10-26_1158.png
    2013-10-26_1158.png
    24.5 KB · Views: 276
I can't make any sense of this at all! I turned off SEF and then the Alert box displayed! Turn on SEF - still working. The SEF business may be irrelevant, I don't know.

I don't understand JS and I suspect never will. I feel like I've been through all this before: Button calls wrong Javascript.

I never discovered what had happened in the other case (now fixed and never returned), but Rob suspected it was a browser cache issue. Could this be the same? Anyway, it makes me a little nervous that these intermittent problems can arise.
 
Could be a cache issue.

Javascript just tends to be a little fragile, as it's so sensitive to which version of which browser it's running in, what versions of which JS frameworks are loaded on the page, and any problem in the JS in any component, module, plugin or template on the whole page (not just Fabrik) can have knock-on error effects.

So if you are of a nervous disposition, Javascript probably won't do your blood pressure any good.

-- hugh
 
I can, Rob, but the problem has disappeared so it's probably not worth it.

You checked my previous post on a similar issue (Button calls wrong Javascript) and you couldn't reproduce it.

Though it failed in both Chrome & Firefox, it must be something to do with me, I think. As Hugh notes, JS is not for the faint-hearted!
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top