Foros del Web » Programando para Internet » Jquery »

duda con jquery + .html()

Estas en el tema de duda con jquery + .html() en el foro de Jquery en Foros del Web. hola a todos, tengo una funcion function createMarker(point,html, name) { var marker = new GMarker(point); var linkid = "link"+(gmarkers.length); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); lastlinkid=linkid; ...
  #1 (permalink)  
Antiguo 09/02/2011, 09:24
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
duda con jquery + .html()

hola a todos, tengo una funcion

function createMarker(point,html, name) {
var marker = new GMarker(point);
var linkid = "link"+(gmarkers.length);

GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
lastlinkid=linkid;
});
// save the info we need to use later for the side_bar
gmarkers.push(marker);

$("#side_bar").html('<a href="#" id="1" >aca</a>'); //esto es probando
return marker;
}

que es llamada aca

$.ajax({
type: "GET",
url: "todos.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('inmueble').each(function(){
var id = $(this).attr('id');
var lat = $(this).attr('lat');
var lng = $(this).attr('lng');
var html = id +"<br />";
html+= $(this).attr('dir')+"<br />";
var point = new GLatLng(lat,lng);
var marker = createMarker(point, html, "label")
map.addOverlay(marker);
});
}
});

y aca le asigno una funcion a cada "a"

$("a").click(function(){
alert("hago alert");
});


en el div side_bar me muestra bien los <a href="#" id="1" >aca</a>
pero no me llama me ejecuta la funcion antes escrita, sin embargo si escribo un enlace en otra parte, es decir no creado por la funcion createMarker()

si funciona, alguna idea por favorr ???


$("#side_bar").html('<a href="#" id="1" >aca</a>');
  #2 (permalink)  
Antiguo 09/02/2011, 09:43
Avatar de iviamontes  
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 13 años, 3 meses
Puntos: 209
Respuesta: duda con jquery + .html()

y bueno lo solucioné pasando la función

$("a").click(function(){
alert("hago alert");
});

para dentro de la funcion createMarker.....
hilo cerrado

Etiquetas: html
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:28.