Javascript: changes are not updated

mariluzrm

Member
Hello.

In a dropdown element of a repeat group I am including javascrip code to hide / show other elements of the same group. I have first included code in the "load event" and it works, but in the "change event" it doesn't work (I can't even see it with the browser debugger). Why doesn't it work at the "event change"?

The code is:

var sel = this.getValue();
var repeat = this.getRepeatNum();

var field1 = this.form.formElements.get('componte___MACIZOEX_'+repeat);
var field2 = this.form.formElements.get('componte___CAR_TIR_'+repeat);
var field3 = this.form.formElements.get('componte___NLINCENT_'+repeat);
var field4 = this.form.formElements.get('componte___NLINDCHO_'+repeat);
var field5 = this.form.formElements.get('componte___NLINIZQ_'+repeat);
var field6 = this.form.formElements.get('componte___NCABCENT_'+repeat);
var field7 = this.form.formElements.get('componte___NCABDCHO_'+repeat);
var field8 = this.form.formElements.get('componte___NCABIZQ_'+repeat);
var field9 = this.form.formElements.get('componte___TIPOHAST_'+repeat);
var field10 = this.form.formElements.get('componte___LUZ_'+repeat);
var field11 = this.form.formElements.get('componte___CANTOMAX_'+repeat);
var field12 = this.form.formElements.get('componte___CANTOMIN_'+repeat);


if (sel!=="1" && sel!=="0"){
field10.hide();
field11.hide();
field12.hide();
}

if (sel!=="5" && sel!=="0"){
field1.hide();
field2.hide();
field3.hide();
field4.hide();
field5.hide();
field6.hide();
field7.hide();
field8.hide();
}

if (sel!=="8" && sel!=="0"){
field9.hide();
}


Also, on some occasions, I change javascript code and it does not update it (I do not see it updated in the browser debugger either). I have tried to clear the browsing history in Chrome and sometimes it updates and sometimes not. Why?

Thanks!!!
 
Did you clear all Joomla and browser cache after JS modifications? Browser with hard relead (in Chrome only possible if the dev console is open).
Did you exclude Fabrik from 3rd party JS and CSS compression (if you have some)?
During development you can enable "Burst JS" in Fabrik Options/Debugging to force automatic JS reload
 
There's a very simple, but effective way to check if the changes in your code are being reflected and not the cached version loaded instead.

Just add something like console.log("1"); in your code and every time you make a change, increase the number by 1.

And of course you can "console.log" your variables in your change event code to see that they are what they should be.

If you don't see anything in the browser console, Troester's tips will probably help.
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top