I'm trying to change src dynamically through jquery in a Phonegap Build application, like this
$('#photo_profile').attr('src', fullPath).one("load", function(evt) {
console.log("load");
}).each(function() {
if(thisplete) $(this).load();
});
But it seems that the img does not refresh while the "load" log is shown each time I change the src.
fullPath
is something like file:///storage/emulated/0/MyAppFolder/Media/Profile%20Photos/profile.jpg
And it's a valid path, as if I kill the app, then re-launch it, the displays the correct image.
Am I doing something wrong? Thanks
I'm trying to change src dynamically through jquery in a Phonegap Build application, like this
$('#photo_profile').attr('src', fullPath).one("load", function(evt) {
console.log("load");
}).each(function() {
if(this.plete) $(this).load();
});
But it seems that the img does not refresh while the "load" log is shown each time I change the src.
fullPath
is something like file:///storage/emulated/0/MyAppFolder/Media/Profile%20Photos/profile.jpg
And it's a valid path, as if I kill the app, then re-launch it, the displays the correct image.
Am I doing something wrong? Thanks
Share Improve this question asked Nov 7, 2014 at 13:13 ApheXApheX 6852 gold badges10 silver badges28 bronze badges1 Answer
Reset to default 4Sounds like caching issue. Try to prevent it with some random parameter:
$('#photo_profile').prop('src', fullPath + '?' + Math.random())
Also src
is a property, so it makes sense to use prop
instead of attr
.