• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Custom Javascript callbacks?

Custom Javascript callbacks? 7 years 10 months ago #35191

I have a long form, using ajax validation. If the error is on a field close to the top of the form, the user gets not indication that there is a problem. Click submit and nothing happens. We would like the form to scroll to the top-most field with errors.

For the time being I hacked it with the following custom js:
function ajaxDisplayValidationErrors(formComponents, task, formId, data) {
  setTimeout(function(){jQuery('html, body').animate({scrollTop: jQuery('.rsform-error').offset().top - 100}, 500);},1000);
  return RSFormPro.Ajax.displayValidationErrors(formComponents, task, formId, data);
}
Basically it overrides the RSForm definition of the ajaxDisplayValidationErrors function and assumes we will have the error classes added after 1 second. (duct tape, I know).

I noticed that in /media/com_rsform/js/script.js there is a section about callbacks (fancy!)...

On line 678 it seems to be calling callbacks after ajax validation:
RSFormPro.callbacks.runCallback(formId, 'afterValidationFailed');
and then on line 703 there is a whole section about adding and executing callbacks.

This is very exciting to I tried doing my scroll-to-top-upon-ajax-validation-error using a callback instead.

I created a function and tried adding it to the RSform callbacks but nothing happened:
jQuery(document).ready(function(){
  RSFormPro.callbacks.addCallback('userform', 'afterValidationFailed', ['myAfterValidationFailedScrollTop']);
  console.log(RSFormPro.callbacks.allCallbacks);
});
function myAfterValidationFailedScrollTop() {
  jQuery('html, body').animate({scrollTop: jQuery('.rsform-error').offset().top}, 500);
}
Anybody here has experience with these callbacks? Can you provide some help?
The administrator has disabled public write access.

Custom Javascript callbacks? 7 years 8 months ago #35558

Hi rubenreyes, I was wondering if you have ever figured this out?

I have something similar but not as complex. I just want to run a js function on successful completion, in this instance i want it to hide the form an the article that it is embedded in.

From your poking around in the script.js file have you found anything that might help accomplish this?

Thanks

Roman
The administrator has disabled public write access.

Custom Javascript callbacks? 2 years 10 months ago #41315

  • info2392
  • info2392's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
I know this is a very old topic, but I found it yesterday and it helped me to solve the problem of running a custom script AFTER the ajax-validation.

The problem with the callback-registration of rubenreyes is, that the formID is not the text-id of the html-tag, but the internal database-id of rsformpro. You'll find the number in the list of forms in the RSForm-Component in you Backend.
The second problem is, that the callback was written in quotation-marks, but the name of a callback.

So here's the correct callback-registration, that is working fine:
RSFormPro.callbacks.addCallback(5, 'afterValidationFailed', [myAfterValidationFailedScrollTop]);
If needed, you can add additional values (strings, variables, ...) inside the array after the callback-function. These values will be sent to your callback-function as arguments.
RSFormPro.callbacks.addCallback(5, 'afterValidationFailed', [myFunction, 'arg1', var2]);
function myFunction(arg1, arg2) {...}
I found the following callbacks in RSForm (version 2.3.20):
  • nextPage
  • changePage
  • afterValidationFailed
  • nextPageFailed
  • afterValidationSuccess
  • nextPageSuccess

Michael
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!