[SOLVED] Javascript | Apply form when dropdown option chosen or date element filled in + SOLUTION

marcq

Member
Hi,

Is it possible to apply (form is saved but not closed) when the user is choosing an dropdown option or filling in a date element ?

Could you please explain me shortly ?

Thanks in advance, cheers, marc
 
You should be able to do this:

Code:
this.form.mockSubmit('apply');

... in the onChange event for the element.

If you need to be more specific, eg. only when the dropdown has a certain value, you'd have to do you own test, like ...

Code:
if (this.getValue() == '2') {
   this.form.mockSubmit('apply');
}

NOTE - if you don't have an Apply button on your form, you'll have to do a github update to pick up this change I just made:

https://github.com/Fabrik/fabrik/commit/989d92adb41d607d2df58f6cbc2c38474478d86b

... which allows specifying the 'apply' to the mockSubmit() even if you don't have an Apply button on your form.

-- hugh
 
Great, it works fine Hugh, thanks again for your always prompt and useful support.

Corollary to this issue when the form is applied, I would like the user not to loose the focus on the group tab and|or element.
Is this possible ?

Solution from Hugh to #1

JavaScript:
function applyDropdown() {

  // GET FORM REFERENCE
  var form = Fabrik.getBlock('form_59');
 
  if (form.formElements.get('gprh_fabrik_user_registration_332_repeat___type_finance_entree').getValue() != '') {
    form.mockSubmit('apply');
  }
};

function applyDate() {

  // GET FORM REFERENCE
  var form = Fabrik.getBlock('form_59');
 
  if (form.formElements.get('gprh_fabrik_user_registration_332_repeat___date_envoi_facture_fe').getValue() != '' ||  form.formElements.get('gprh_fabrik_user_registration_332_repeat___date_envoi_facture_fe').getValue() == '0000-00-00 00:00:00')  {
    form.mockSubmit('apply');
  }
};
 
You'd have to roll some code to remember the state and re-apply it on the reload, there's nothing baked in to do that, and it's not something I can write off the top of my head for you.

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

Thank you.

Members online

No members online now.
Back
Top