Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×

API scripts not triggering change:attribute the first time a attribute is changed but afterwards it works fine?

1621787910

Edited 1621788259
So i have like a normal input field with some attr name like <input name="attr_influence" class="characteristic-input" type="number" value="0"> And simple test API script like on('change:attribute', (ev) => {     const eventName = ev.get('name');     log(eventName); } So the first time i change the value in the input field i dont get an event triggered, but aftwards the event triggers fine. Is this a known issue or am i missing something?
1621811171
The Aaron
Roll20 Production Team
API Scripter
It's possible the first "change" is actually creating the attribute, in which case it would get an "add:attribute" event.  Give this a try: on('add:attribute', (ev) => { const eventName = ev.get('name'); log(`Added Attribute: ${eventName}`); } on('change:attribute', (ev) => { const eventName = ev.get('name'); log(`Changed Attribute: ${eventName}`); }
The Aaron said: It's possible the first "change" is actually creating the attribute, in which case it would get an "add:attribute" event.  Give this a try: on('add:attribute', (ev) => { const eventName = ev.get('name'); log(`Added Attribute: ${eventName}`); } on('change:attribute', (ev) => { const eventName = ev.get('name'); log(`Changed Attribute: ${eventName}`); } Yep that was it! Thanks as always
1621856863
The Aaron
Roll20 Production Team
API Scripter
Great!  No problem. =D