rm
Apprentice

Rule dont apply after update value with javascript

Jump to solution

Hi,

I use javascript to update a value of a textfield (txtStepID) in my Nintex Form. There are several formatting rules on different controls triggered on this value. Since upgrading to nintex Form from V 2.4.0.0 to 2.5.0.0 the rule is not recognized anymore. I see the value changes due to the step but the rule just don't fire. If I change the field value manually in the textbox the rule is working perfectly.

Here is the javascript I use to update my textbox value:

function goNext() {

    var txtStep = NWF$("#" + txtStepID);

    var stepNumber = txtStep.val();

    stepNumber++;

    goStep(stepNumber);

}

function goPrev() {

    var txtStep = NWF$("#" + txtStepID);

    var stepNumber = txtStep.val();

    stepNumber--;

    goStep(stepNumber);

}

function goStep(stepNumber) {

    var txtStep = NWF$("#" + txtStepID);

    txtStep.val(stepNumber);

    txtStep.trigger("change");

}

Tags (2)
Reply
4 Replies
rm
Apprentice

Re: Rule dont apply after update value with javascript

Jump to solution

Found it:

...Since V 2.5.x.x Nintex Forms is triggering rule events onblur instead onchange

Therefore I had to change my code as follows:

txtStep.trigger("blur");

Reply
pramod_nagaraj1

Re: Rule dont apply after update value with javascript

Jump to solution

This perfectly works. Thanks Roman Mellenberger

Cheers

Pramod

0 Kudos
Reply
bimi82
Contributor

Re: Rule dont apply after update value with javascript

Jump to solution

May I ask what this script does?

I fail to reproduce the same ...

maybe screenshots (before / after) would provide more information

0 Kudos
Reply
Rayamondo
Scholar

Re: Rule dont apply after update value with javascript

Jump to solution

Hey Bimi82,

 

I searched for this issue after noticing rules weren't running after I was updating a field value with JavaScript.  When changing the field value manually on the form the rules did work so I knew something wasn't refreshing/triggering.  My original (and simple ) code was:

 

function navButtonClicked(n) {
    NWF$('#' + js_navButtonSelection).val(n);
}

 

As per the instructions here I added the '.trigger("blur");' and it worked great!  The field was being populated with the new value and the rules ran properly (in my case showing/hiding sections).

 

function navButtonClicked(n) {
    NWF$('#' + js_navButtonSelection).val(n);
    NWF$('#' + js_navButtonSelection).trigger("blur");
}
Reply