Comunidad de diseño web y desarrollo en internet online

Problemas con JQUERY al usar en forma asincrónica

Citar            
MensajeEscrito el 23 Ago 2009 05:46 pm
Primero quiero agradecerles por su ayuda, especialmente a Nachon, ahora vuelvo a solicitar ayuda….. les explico tengo una página principal donde en la cabecera tengo una menú desplegable por donde llamo a partes de código por load(), ejemplo inicio.php, cursos.php, capacitación.php, etc pero en el archivo cursos.php tengo un span.mas donde al hacer click por medio de JQUERY hago que oculte y muestre información de un div.oculto. Esto funciona perfectamente si llamo al archivo por ejemplo http://localhost/be2/capacitacion/cursos.php pero si ya llamo mediante load y se incluye en la pagina principal no me funciona, si alguien podría ayudarme le agradeceré mucho.
Mi archivos son:
Funciones.js
$(document).ready(function(){
$('p.oculto').hide();
$('span.mas').click(function() {
$('p.oculto').show();
});

jQuery(function(){
jQuery('ul.sf-menu').superfish();
});

$('#contenedor').addClass('contenedor');
$('td#head').flash(
{ src: 'inc/bann.swf',
width: 955,
height: 110 },
{ version: 8 }
);

$('td#nav').addClass('nav');
$('td#noti').addClass('noti');

jQuery.noConflict();
function pageload(hash) {
// hash doesn't contain the first # character.
if(hash) {
// restore ajax loaded state
jQuery("#conte").load(hash);
} else {
// start page
jQuery("#conte").empty();
}
}

// Initialize history plugin.
// The callback is called at once by present location.hash.
jQuery.historyInit(pageload);

// set onlick event for buttons
jQuery("a[rel='history']").click(function(){
//
var hash = this.href;
hash = hash.replace(/^.*#/, '');
// moves to a new page.
// pageload is called at once.
// hash don't contain "#", "?"
jQuery.historyLoad(hash);
return false;
});
});
Y cursos.php

<p>Presione <span class=”mas”>aquí</p> para ver</p>

<p class=”oculto”>Texto Oculto</p>

Por Jamilin

3 de clabLevel



 

Bolivia

firefox
Citar            
MensajeEscrito el 25 Ago 2009 12:30 pm
Hola Jamilin. Me alegro de poder ayudarte.

El problema que tenes aca es mas bien conceptual. Si vos cargas paginas por ajax debes tener en cuenta un nuevo orden de ejecución.

La función load de Jquery dispone de un callbak donde podes incluir otra funcion que sera ejecutada una vez completado el load. Es ahí donde debes poner tu funcion para mostrar y ocultar.

Seria algo asi.

function pageload(hash) {
if(hash) {
jQuery("#conte").load(hash, function(){
$('p.oculto').hide();
$('span.mas').click(function() {
$('p.oculto').show();
});
} else {
jQuery("#conte").empty();
}
}

Intentalo y despues me contas. Saludos!

Por nachon

22 de clabLevel



 

Argentina

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.