Updating input value with JQuery not working

Hi,
2 things.
First
Why do you use jquery to update the value and not doing it directly with AppConnect?
Second
I had a similar issue where the updated value was always a step front, just like it happens to you where ServerConnect takes the old value. I solved this by passing the value into a cookie. Try saving your updated value into a cookie and then use this cookie value as the value for the input too.

Thank you.

I will try the cookie way.

I am using a JavaScript library so i must set the value with JavaScript.

I think there was a post that was showing how to use AppConnect to pass values into javascript. Maybe it could help or at least make your life easier. Will post it here if I find it.

I think it was this one but is not exactly what I was thinking of.

Thanks

1 Like

Well of course i tried that as i said in my post.
It doesn’t update the value for the input in app connect.

This might be a totally silly answer but can you not use the built in dmx variables so they all talk to each other at the correct times. Something like I did here possibly. Even though my usage was for php it should be similar to adapt for your usage I would imagine.

1 Like

Yes this is why I said that it was not what I was thinking of

Another post that might help was this Using an HTML editor with Wappler where Patrick says use the onupdated event instead of the onchange.

2 Likes

Yes this is what I was looking for

Using $('#Search').val('newValue').trigger('change'); is the correct way to do it. You only have to know that data bindings used expressions get updated later. If you want to use the updated data it is best to use the updated event, that is triggered after all data bindings are updated.

So i use my action with the updated dynamic event? and keep my Javascript code the same?

yes, the updated event comes later and makes sure that the data inside App Connect is updated. App Connect also listens to the change event to update its data, but when your event listener is called before the one of App Connect you get the old data.

the updated event is not firing.

How do you bind it exactly? Can you paste the code here?

i have this in the dynamic updated event
browser1.alert("Updated!")

it will only fire when i do something else on the page after setting the value with JavaScript. for example typing in any other input field

For your custom js code use the static onupdated event.

I don’t want to run any custom js code on the updated event of the input.

I want my js code to start The dynamic updated event on the input.

so after another day
there is an issue with app connect not picking the new value until the user do UI interaction.
i even did as @t11 suggested and used a cookie. but the same issue is also present. app connect is one step late in the value of the cookie also.
here is my cookie setting code.
document.cookie = 'qr_code='+last_code;

and my solution was to not use app connect search parameter and access the cookie from server side actions and it work.