Reputation: 49364
This might be a really simple issue but I cannot spot the problem.
I have this code:
output += '<li><a href="#"><img src="'+value.thumbnail_url+'" /><h3>'+value.title+'</h3>'+value.body+'</a></li>';
I need to add this code after the href="#"
and replace the url string with this: value.media_url
I've come up with:
output += '<li><a href="#" onclick="window.plugins.childBrowser.showWebPage('+value.media_url+');"><img src="'+value.thumbnail_url+'" /><h3>'+value.title+'</h3>'+value.body+'</a></li>';
but there seems to be a syntax issue with the above as the link is not working.
The broken code is somewhere here: onclick="window.plugins.childBrowser.showWebPage('+value.media_url+');"
as the rest works fine.
I could go even further ... here:
('+value.media_url+')
Can anyone see the problem?
Upvotes: 1
Views: 74
Reputation: 35572
replacing onclick="window.plugins.childBrowser.showWebPage('+value.media_url+');"
with onclick="window.plugins.childBrowser.showWebPage('"+value.media_url+"');"
will fix it
Upvotes: 1
Reputation: 324610
The resulting string is:
window.plugins.childBrowser.showWebPage(my/url/to/file.png)
As you can see, it's missing quotes around the string. Since it's in an attribute, you need this:
... onclick="window.plu.....WebPage("'+value.media_url+'")" ...
Upvotes: 2