I sending the API a remote image url. The API does some image processing, then uploads to AWS S3. If successful, it returns the url to the image in response.data.attributes['image-url']
My controller has:
imageUrl: Ember.computed.oneWay('model.imageUrl');
actions: {
uploadImage(imageUrl) {
Ember.$.ajax({
url: `api/v1/users/1/update-image`,
type: 'PUT',
data: {
data: {
attributes: {
'image-url': imageUrl
}
}
}
})
.success(response => {
this.set('imageUrl', response.data.attributes['image-url']);
})
.error(response => {
console.log(response);
});
}
}
My template has:
<img src={{imageUrl}}>
API always returns something like http://ift.tt/1oipEAv. Even if image.jpg is an entirely new image.
Ember does not rerender the img element. I have to manually refresh to see the new image on the browser.
Is there any way I can tell Ember that the img element contains a new image and that it should re-render it?
Is there a different approach I should consider instead?
Aucun commentaire:
Enregistrer un commentaire