im having this issue and trying to make it work with no luck yesterday.
i have text input with ID Search
in my JavaScript i set the input value like this: $('#Search').val('newValue').trigger('change');
after the javascript is executed i see the new value in the input correctly.
however when i run a server connect with the text input value as a parameter it show as empty field (the old value is empty). and if i run the server connect again the value is updated
@patrick
how can i tell app connect to update the input value when i change it in JavaScript trigger('change') didn’t update the value only triggered the dynamic change event.
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.
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.
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.
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.
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.
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.