Javascript on calc element / element with default

joit

Active Member
Hi,

I have an element with default calculation (usergroup field). I want to have some javascript on it, hiding fields for other usergroups. I set the Javascript onload, but it won't work.
Is there an alternative?
 
It's probably becouse when the Javascript runs, there's nothing in the usergroup field yet. Do you think there's a workaround?
 
Thanks Hugh,
this works great on the usergroup field itself.
I have another calc element, that generates a nice readable name out of the usergroup ID.
The Javascript still doesn't work on this one. Should this work with your fix, too?
 
Note that with calc elements, if you enable 'calc on load' you don't really need a load event, as we fire the 'change' event on the element when the AJAX calc happens. So just a 'change' event should do it.

That said, the change I made is probably necessary anyway, as it wasn't taking into account the value of an element being "null". Although after an AJAX update, a calc should no longer be null, even if the AJAX call returns nothing, it should become an empty string, which won't break the Array.from(this.get('value').contains() ... which fails when null because the Array.from() is then null. But an Array.from() on an empty string yields an empty array, which is OK.

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

Thank you.

Members online

No members online now.
Back
Top