我试图在谷歌地图信息窗口中捕捉点击按钮事件。为此,我有以下内容
<!-- Html file -->
<template name="infoWindowContent">
<button>Click Me!</button>
</template>
然后我在client.js上有这个
//Client js file
//Function that renders the template. Gets called from a user's action
function showInfoWindow(map, marker) {
var infoWindow = new google.maps.InfoWindow();
//This is the line that generates the template's html
var infoWindowHtmlContent = Template.infoWindowContent();
infoWindow.setContent(infoWindowHtmlContent);
infoWindow.open(map, marker);
}
//Template events
Template.infoWindowContent.events = {
'click button': function(event){
console.log('event was triggered', event);
}
}
infoWindow 显示在地图上并包含按钮,但是当单击该按钮时,控制台中不会显示任何日志。对此有任何线索吗?如何捕获由使用 Template.myTemplate() 呈现的某些元素调度的事件?