问题
I am using Jquery load() to load external pages inside a DIV, so far so good, the problem is, in one of these external pages I need to do a slideToggle effect but it doesn't work at all, I believe it's because the load(). here's some code I am using.
This is the project itself. http://www.universidadedoingles.com.br/apamagis/apamagis/teste.html
On the left menu, click on CADASTRO, then NOVO ASSOCIADO, this is an external page, at the top there is an gray anchor PRINCIPAL, when the user clicks there it must slide a form I have.
If you guys want to check just the external page, here it is.
http://www.universidadedoingles.com.br/apamagis/apamagis/novoassociado.html
This link above, works properly, but when I am inside the project and call it using load() nothing happens.
In case you're wondering, here's how I am loading the pages and slide. This loads the page I'm having problems
$("#novoAssociado").click(function() {
$("#principal").load("novoassociado.html");
});
This is the code to slide the content
<script type="text/javascript">
$("document").ready(function() {
$("#dadosPessoais").click(function() {
$("#one").slideToggle();
});
$("#localizacaoAnchor").click(function() {
$("#localizacaoContent").slideToggle();
});
});
回答1:
<script type="text/javascript">
$("document").ready(function() {
$("#dadosPessoais").live('click', function() {
$("#one").slideToggle();
});
$("#localizacaoAnchor").live('click', function() {
$("#localizacaoContent").slideToggle();
});
});
try that (live)
回答2:
Your javascript in your novoassociado.html is never getting fired since a document.ready event is never occurs for the content being loaded in from the ajax call. Take the script that Robot Woods has and put it in your teste.html instead of novoassociado.html.
来源:https://stackoverflow.com/questions/5410815/jquery-load-conflicts-with-slidetoggle