0

マーカーをクリックすると、2 つの入力フィールドと 1 つのボタンを含む情報ウィンドウが表示されます。
情報ウィンドウを閉じると、ボタンが押されたかどうかを知りたいと思います。
どうすればできますか?

google.maps.event.addListener(marker[i],"click", function()
    { 
        html = "Name: " + "<input type='text' id='name' />";
        html += "Firstname: " + "<input type='text' id='firstname' />";
        html += "<input type='button' id='okButton' value='OK' />";
        infoWindow[i].setContent(html);
        infoWindow[i].open(map,marker[i]);    
    });  
google.maps.event.addListener(infoWindow[i],'closeclick',function ()
    {  
        //action when the ok button was pressed or not
        //this code doesn't work
        $('#okButton').button().click(function()
        {
            //action
        });
    });
4

2 に答える 2

0

$('#okButton').button().click(function()これは、クリック イベントを処理する正しい方法ではありません。また、ボタンを DOM に動的に追加しています。それを次のように置き換えます。

$(document).on('click', '#okButton', function() {
    //action
});
于 2013-09-26T17:51:18.553 に答える