Jquery load() “conflicts” with slideToggle()

我怕爱的太早我们不能终老 提交于 2019-12-08 11:54:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!