JavaScript Function calls within InfoWindows

Often I have maps with a whole lot of markers (let's say representing shops). I have infowindows that display basic info on the shop represented by the marker, then, on the infoWindow HTML I like to put a button that, for example, says "Details". The html of the infowindow is simple.. the html of the info window would include an

input type="button" value="Show More" onclick="showMore(' + shopId + ');

The relevant shopId would be obviously different for every marker...

The problem is that the showMore function has to be declared as a global function to the javascript otherwise the infowindow doesn't find it.

Lets say that all the code (generating map, placing markers, declaring infowindows, etc) is in a function called function showShops() {} , and the showMore(id) function is inside the showShops() function, HOw can I tell the "onclick" event to call the showMore() function inside the showShops function?

Just to check my code, I've changed it to onclick="alert(' + shopId + ') .. and I correctly get an alert with the relevant shop id..

Answer:1

I want to create a html5 audioplayer for my band's website. The audiofiles are stored in the database as mp3, ogg and wav files to support all major browsers on their current versions. First, all ...

I want to create a html5 audioplayer for my band's website. The audiofiles are stored in the database as mp3, ogg and wav files to support all major browsers on their current versions. First, all ...

I have two static pages from a user which is deployed on their servers. Currently I am making a call to their server from code behind and loading them. But now I don't want to make a code behind call. ...

I have two static pages from a user which is deployed on their servers. Currently I am making a call to their server from code behind and loading them. But now I don't want to make a code behind call. ...

  1. load website inside iframe
  2. load webpage into iframe
  3. html load webpage in iframe
  4. load external webpage in iframe

I read this blog post on how to potentially pass a primitive by reference to a function in JavaScript. At first glance it seems like it could work but I'm wondering what potential pitfalls could come ...

I read this blog post on how to potentially pass a primitive by reference to a function in JavaScript. At first glance it seems like it could work but I'm wondering what potential pitfalls could come ...

I have problem with one native HTML5 canvas function getImageData() on Mac OS. I run test for this function in jsperf with a similar power processors and result is: Ubuntu 14.04 - chrome/opera: 300k ...

I have problem with one native HTML5 canvas function getImageData() on Mac OS. I run test for this function in jsperf with a similar power processors and result is: Ubuntu 14.04 - chrome/opera: 300k ...

  1. html5 canvas slow
  2. html5 canvas performance
  3. html5 canvas performance test
  4. html5 canvas performance tips
  5. html5 canvas performance benchmark
  6. html5 canvas performance android
  7. html5 canvas drawimage slow
  8. firefox html5 canvas slow
  9. html5 canvas is slow