0

我試圖從Bing地圖上放置的窗口標記中的鏈接觸發事件 但是當我點擊鏈接時,我被重定向到一個新頁面而不是JS一個函數綁定到事件jquery-bing-maps點擊事件沒有從窗口標記觸發

$('.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); 
} 

所以基本上是沒有得到顯示警告信息,但網頁會被重定向到test.php的

使用jQuery-1.8.2和jQuery Mobile的1.2

+1

? 'live()'已在1.9中刪除http://api.jquery.com/live/ – wakooka 2013-02-22 11:56:33

+0

您能否向我們提供HTML代碼,以便我們看到您的元素的定義。如果HMTL鏈接中有'single_address',那麼href應該設置爲:'javascript:void();'。 – 2013-02-24 17:17:46

+0

謝謝你的回答@NicolasBoonaert我希望我能幫你解決問題。該鏈接由'description'選項中的Javascript生成,可能由於滾動條而不明顯。我希望能回答你的問題 – Martin 2013-02-25 10:47:08

回答

0

好吧,我設法得到它工作,我不知道我想要做的是什麼實現

我跟了Bing地圖文檔http://msdn.microsoft.com/en-us/library/gg675210.aspx

它要麼可能使標題點擊在titleClickHandler屬性指定的事件處理程序 或者,用動作添加標籤財產

var infoboxOptions = { 
     title:'My Infobox', 
     description:'Testing actions', 
     actions:[ 
      {label: 'test1', eventHandler: testEvent1}, 
      {label: 'test2', eventHandler: testEvent2} 
     ] 
    }; 
您正在使用什麼版本的jQuery