You are viewing limited content. For full access, please sign in.

Question

Question

How to trigger multiple field rules close together

asked on October 14, 2016 • Show version history

Hi all,

On my form I have three radio buttons. Each radio button triggers a different field rule. If I click the radio buttons manually, the fields rules trigger and work as expected.

The problem I'm having is when I try to use JQuery to set and trigger each radio button, only the first one will work. It doesn't matter which of the three I trigger first, only that one will trigger:

$('.radioA input').val(['Yes']).change();
$('.radioB input').val(['Yes']).change();
$('.radioC input').val(['Yes']).change();

I've noticed that if I seperate the .val(['Yes']) functions, I can set all the radio buttons to Yes but I can still only run the .change for one (the other calls are ignored).

Any clue on how to get them all to update?

0 0

Answer

SELECTED ANSWER
replied on October 17, 2016

This worked for me:

 

$('.radioA input:radio:first').trigger('click');
$('.radioB input:radio:first').trigger('click');
$('.radioC input:radio:first').trigger('click');

 

1 0

Replies

replied on October 14, 2016

Have you tried adding a .Delay(300) in to wait a tiny bit before triggering?

I've found that helps with quite a bit of cascading lookups in laserfiche, I imagine it could also apply to rules. 

I've also used setTimeout, but that generally requires you to create a seperate function for what you want to call (if you want it to look legible  at all)

0 0
replied on October 14, 2016

Hi Chris,

I've not tried delay(). I tried using setTimeout for 2000 and 5000 milliseconds. I'll give delay anf your other suggestion a try on Monday.

 

0 0
replied on October 14, 2016

Thought of another thing too... 

 

You might try using 

 

$('.radioA input').find(["Yes"]).attr('checked', true').change();

It essentially does the same thing but in a different way. It's worth a shot at least if the delay doesn't help. 

0 0
replied on October 17, 2016

Turns out there was a bug in my code. It was quite deep in a number of calls but the .trigger code didn't trip it and the .change() code did.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.