I have a problem with jquery parent. I try to access an element by its ID but it still fails. The item is a jquery full calendar plugin and I'm trying to recharge events. Here I leave the code in case someone can help me.
$('.seleccionparacita').live('click', function () {
alert("hi1");
alert($('#pruebaa',window.parent.document).text());//work
$('#pruebaa',window.parent.document).html('adios');//work
var nTds = $('td', this.parentNode.parentNode);
var id = $(nTds[0]).text();
$.ajax({
data: { fecha: $('#fechacita').text(), medico: $('#seleccionmedico').val(), cliente : id },
url: Routing.generate('comprobarcita'),
success: function(data) {
if (data == 1){
$.ajax({
data: { fecha: $('#fechacita').text(), medico: $('#seleccionmedico').val(), cliente : id },
url: Routing.generate('guardarcita')
});
alert("llega");
$('#pruebaa',window.parent.document).html('adios');//work !!!
//down no work no acces id to calendar
//$('#calendar',window.parent.document).fullCalendar( 'destroy');
//$('#calendar',window.parent.document).fullCalendar( 'removeEventSource', citas );
//$('#calendar',window.parent.document).fullCalendar( 'addEventSource', Routing.generate('citasajax',{id: 0}));
//$('#calendar',window.parent.document).fullCalendar( 'refetchEvents' );
alert("hi2");//work
parent.$.fancybox.close();
}
else
alert("Error el médico esta ocupado");
}
});
})
If I try to access from a click of a DOM element works correctly but if I try from a button I can not access the iframe. Here is the code:
$('#pruebaa').live('click', function () {
alert("holita");//work
$('#calendar').fullCalendar( 'refetchEvents' );//work
})
$('.seleccionparacita').live('click', function () {
alert($('#pruebaa',window.parent.document).text());//work
var nTds = $('td', this.parentNode.parentNode);
var id = $(nTds[0]).text();
$.ajax({
data: { fecha: $('#fechacita').text(), medico: $('#seleccionmedico').val(), cliente : id },
url: Routing.generate('comprobarcita'),
success: function(data) {
if (data == 1){
$.ajax({
data: { fecha: $('#fechacita').text(), medico: $('#seleccionmedico').val(), cliente : id },
url: Routing.generate('guardarcita')
});
alert("hi2");//work
$('#calendar').fullCalendar( 'refetchEvents' );//not work
alert("hi2");//not work
parent.$.fancybox.close();
}
else
alert("Error el médico esta ocupado");
}
});
})