Search code examples
javascriptjqueryjquery-mobilebing-mapsjquery-events

jquery-bing-maps click event not triggered from window marker


I am trying to trigger an event from links within Window markers placed on Bing Maps however when I click on the links I get redirected to a new page rather than having JS to bind a function to the event

$('.single_address').live('click', function (evt) {

    alert('test');
    return false;
});


for (var i = 0; i < locations.length; i++) {
 (function (i) {
   var location_id = locations[i].aid;
   var address_street = locations[i].d;
   // var self = this;

   self.addMarker({
    'location': locations[i].la + ',' + locations[i].lo,
    'bounds': true
   }).click(function () {self.openInfoWindow({
    'title': address_street,
    'description': '<div class="single_address"><a href="test.php#list1">Contacts at this address</a></div>'
            }, this);
        });

    })(i);
}

so basically the alert message is not getting displayed but the page is redirected to test.php

Using jquery-1.8.2 and Jquery Mobile 1.2


Solution

  • ok, I have managed to get it working, I am not sure what I was trying to do is something achievable

    I have followed Bing Maps documentation http://msdn.microsoft.com/en-us/library/gg675210.aspx

    It is either possible to make the title clickable specifying an event handler in the titleClickHandler property Or, add labels with the actions property

      var infoboxOptions = {
             title:'My Infobox',
             description:'Testing actions',
             actions:[
              {label: 'test1', eventHandler: testEvent1},
              {label: 'test2', eventHandler: testEvent2}
             ]
       };