简体   繁体   中英

Polymer.js Data binding is not updated after setting input value with JQuery

I have the following html:

<img id="avatar" src="[[avatarUrl]]" />
<input id="avatar-url" type="text" placeholder="avatar url" value="{{avatarUrl::input}}" />

And js:

avatarUrl.val( profile.avatarUrl );
avatarUrl.trigger("input");

This code is setting the input value, but polymer doesn't update img's src attribute.

I tried triggerHandler but it is also not working.

Maybe instead of this: value="{{avatarUrl::input}}"

you need this? value="{{avatarUrl::change}}"

I'm not sure but I think that your use of square brackets ([[]]) is the problem. I don't have acces to the computer so I can't check it but try to change to <img src="{{avatarUrl}}">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM