• New Commercial Services Section

    We have now opened a commercial services section here on the forum. If you have a Fabrik project that you wish to have someone work on for you, post it under Help Wanted. If you are an application developer and wish to earn some money helping others, post your details under Fabrik Application Developers.

    Both of these are unmoderated. It will be up to both parties to work out the details and come to an agreement.

[SOLVED] Submit on JS-Event

mudshark79

Member
I'm sure there is quite a simple way to "push the submit button" via a Element-JS? Even though reading and trying quite something I didn't find out yet...

Can someone point me to the right direction, please?

Thanks
 
Try ...

Code:
var form = Fabrik.getBlock('form_X');
form.doSubmit(new Event.Mock(form._getButton('Submit')), form._getButton('Submit'));

Replace X with the numeric ID of your form, like form_7.

-- hugh
 
Try ...

Code:
var form = Fabrik.getBlock('form_X');
form.doSubmit(new Event.Mock(form._getButton('Submit')), form._getButton('Submit'));

Replace X with the numeric ID of your form, like form_7.

-- hugh

Thnkas, seems I was not even Close with m y own Tries :). Also I did manage to mix up Apply and Submit while posting and for the sake of completeness and because it somehow not intuitive, here the same code for "apply" with initial lower-case letter:

Code:
var form = Fabrik.getBlock('form_X');
form.doSubmit(new Event.Mock(form._getButton('apply')), form._getButton('apply'));

Regards,

Matthias
 
Thanks for the feedback.

You can also use a "non Fabrik" approach, and fake a click event on the DOM element for the button, but calling our doSubmit() method directly avoids some potential gotchas. The only wrinkle being that you have to use that Event.Mock() thing to create an event object, with a valid button as the target of the event, as doSubmit() does slightly different things depending on which button was clicked.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top