I have a little Google Maps app that draws markers with an Info Window. I'd like to be able to edit the info in the window and submit if. I can do this - but only once. I looked here Adding event to element inside Google Maps API InfoWindow which helped a bit, but with my code the submit event doesn't seem to fire.
Here is my code:
// get the data
$.getJSON( 'csvToJson.php', function(data) {
// Loop through it
$.each( data, function(i, m) {
// Add the marker
var title = m.Namn + ': ' + m.Meddelande;
$('#map_canvas').gmap('addMarker', {
'position': new google.maps.LatLng(m.Lat, m.Lng),
'bounds':false,
'title': title }
).click(function() {
// Initialise the info window
var divName = "detail" + m.id; // come back to this?
var infoWindowContent = [
"<form id='detail_form' action='bib.php' method='post'>",
"Namn: <br><input type='text' name='Namn' value='" + m.Namn + "'></input>",
"<br>Meddelande: <br>" + m.Meddelande,
"<br><input type='submit' value='Spara ändringar'></input></form>"
].join("");
var info = new google.maps.InfoWindow({
content: infoWindowContent
});
google.maps.event.addListener(info, 'domready', function() {
$(document).off("submit");
$(document).on("submit", (function() {
console.log("Hi");
})); // end addEvent
}); // end addListener
$('#map_canvas').gmap('openInfoWindow', info, this);
}); // end addMarker click(function)
}); // end $.each
}); // end $.getJSON
All help appreciated.
Mini