Forums

calling jquery function

mauriciocgpereira 03 Jul, 2014
Hi,

I've got a jquery function that slides the page to the top of the browser window.

I wanto to call this function onSubmit, so that the page slides top before the form after the validation, but before the data is submited and the page reloaded to show the submission message.

How can I do this?

Thanks in advance
mauriciocgpereira 03 Jul, 2014
* I want to call this function onSubmit, so that the page slides top after the validation, but before the data is submited and the page reloaded to show the message.

sorry for my bad english!
GreyHead 04 Jul, 2014
1 Likes
Hi mauriciocgpereira,

I was testing this for some Google Analytics last week and I was unable to find a way of triggering an event in CFv5 after validation and before submission ;-(

Hopefully Max will add an onSuccess event to the validation script in a future release.

Bob
mauriciocgpereira 04 Jul, 2014
Thanks :-)

And I can I call a jquery function onSubmit?

Thanks
GreyHead 04 Jul, 2014
Answer
Hi mauriciocgpereira,

Yes - but I think that it will run before the validation, not after it.

Bob
GreyHead 04 Jul, 2014
1 Likes
Hi mauriciocgpereira,

It will be something like this in a Load JS action in your form on Load event:
jQuery(document).ready(function (jQ) {
    jQ('#your_form_id').on('submit', function(el){
       // some script here
    });
});
Note, this is set up to use jQ in place of $ in the JQuery script.

Bob
mauriciocgpereira 04 Jul, 2014
Can't see how to put this to work
Here is the function:

jQuery(document).ready(function (jQ) {
    jQ('#chronoform-newsletter-form').on('submit', function(el){
                var href = jQuery(this).attr("href");
                alert(href);
    });
});


At this first stage I only want to detect the href and display it in a alert box.

Should I put anything in the JS Files field?

Thanks in advance
This topic is locked and no more replies can be posted.