"Onchange" and the IDE's "On Change"

"Onchange" and the IDE's "On Change"

  
Hi OS community,

I am learning in my free time the cool Outsystems' system and now seek assistance/advice from the community to help make my little problem go away.

The problem (we'll what I believe to be the problem anyway) is that I am using the OS IDE's "On change" event to do some AJAX refreshing when a value is changed but also I have the currency input widget operating on the same input and after taking a quick glance at the JS that the widget uses, it seems to be calling the onchange event also which I am sure is causing the problem that when the input boxes value is changed, it is correctly formatting but it is not calling the AJAX refresh. I can only presume my IDE On Change event is being overridden by the widgets onchange event.

My problem is that I want to call the widget to format on change and then also perform an AJAX refresh if the value changes....

I have attached a sample with my problem... please pay attention to the screen "Dog_CostEdit" & "Item Cost"

Looking forward to your assistance / advice.

Thank you

Hi Mark,

The usual problem with javascript widgets is that they create dummy inputs and hide the real one. Then keep updating the real one with a non-formatted value.

The platform onchange is only triggered if the real input has focus when the change happens. That's the reason why most JavaScript based widgets have problems working together with the platform onchange.

In some cases you can change your widget JavaScript to .focus () the hidden input before changing it, in others (most likelly the currency format) is not so easy because it can break the user typing.

(writing this from my phone atm so can't look at your specific case ..just wrote this based on past experiences I had on widgets like auto-complete or calendar)

Regards,
João Rosado
Hi Mark,

Have you tried this component from OS Forge? 

Best Regards,
Rafael Pereira



Rafael Pereira wrote:
Hi Mark,

Have you tried this component from OS Forge? 

Best Regards,
Rafael Pereira


 
 Hi Rafael,

Yes I have tried input masks however I do not like the mechanism of how it deals with decimals. What i mean by that is if you want to type the value 10 with the input mask having 2 decimals places then you need to type 1000 which in my view would potentially confuse end-users (like me when I am in a hurry :) )
 
Thanks
Hi,
I didn't know if I fully understood your issue, but, since you want to do two different thinks and you can't attach two onchange actions, you can do one using onchange and the other one using the onblur event.
This way you can separate the two events and treat each one according to your needs.

Kind Regards,
GM
Hey GM,

Yes you understood me and confirmed my thoughts.

I attempted your suggestion but for me it did not work. Could I trouble you to look at my OML attached above and see if you can try you suggestion? I am not strong in JS :)

Thanking you in advance.


Hi Mark,

I'll look at your oml as soon as possible, there's no problem ;)

Best Regards,
GM
Thanks GM. Look forward to seeing if you can help me.

Hi Mark,

Sorry about the late reply but I had some problems..
Can you give me a more specific example about what you need to do?
You need to perform theaction implemented in the onchange event, then apply the format widget and after these perform another action?
Give me more information and I'll reply faster then the last time...:)

Best Regards,
Gonçalo Martins
Hi Gonçalo,

What I would like to do in my example is be able to use the ‘currencyinput’ widget in the screen 'DogsHome_Edit' to format the input fields of DogCost_Qty & DogCost_Item_Cost and when the value changes in either of these inputs then be able to perform the action OnDogCost_Change which calculates the line item total by multiplying out the item Quantity and Item Cost (you can see this in the action) and then refresh the screen with AJAX to reflect the new ‘line total’.

Maybe my whole approach is incorrect, so any help or pointers / examples would be really appreciated. (I am very new to OS)

Again, thank you for your assistance.

Regards, Mark