php - Adding event listener on all $.goMap markers on the map -


i have been trying add click listener every single marker on map created jquery extension $.gomap.

this how load markers map:

$.getjson('get_markers.php', function(data) {     $.each(data, function(pair) {         id = data[pair]['id'];         $.gomap.createmarker({             latitude: data[pair]['lat'],             longitude: data[pair]['lng'],             draggable: false,             html: {                 ajax: 'marker_description.php?q=' + id,                 content: 'loading...'             }         });     }); }); 

i looked html see if figure out id or class of markers, use jquery attach click listener of them, couldn't find them in html markup.

i solved adding listener each marker in loop after creating them. added id attribute marker in order create listeners.

$.getjson('get_markers.php', function(data) {     $.each(data, function(pair) {         var id = data[pair]['id'];         $.gomap.createmarker({             latitude: data[pair]['lat'],             longitude: data[pair]['lng'],             draggable: false,             id: id             /*html: {                 ajax: 'marker_description.php?q=' + id,                 content: 'loading...'             }*/         });          $.gomap.createlistener({type:'marker', marker:id}, 'click', function() {                  $.ajax({                   url: "show_post.php?q="+id,                   success: function(html){                     $("#results").html(html);                   }                 });             });      }); }); 

would hurt performance though? not sure.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -