0

After an ajax call I cannot edit the content of the with ajax pulled content anymore.

I cannot edit the contents of the content div anymore. Neither .show() nor .animate() do work anymore.

Does anybody have an idea what is going on?

index.php

if (!empty($uri)) {
    $first = substr($uri, 0, 1);
    if ($first == '/') {
        $uri = substr($uri, 1);
    }
    if (!empty($uri)) {
        $uri = explode('?', $uri);
        $uri = explode('/', $uri[0]);

        if (isset($uri[1])) {
            $page = $uri[1];
            } else {
            $page = array_shift($uri);
            }

        if ($uri[0] == 'blanc' && empty($uri[1])) {
            $page = 'profile';
        }   
    }
}

$content = Helper::getContent($page);

if (!empty($_GET['ajax'])) {
    echo $content;
} else {
    require_once ('template.php');
}

?>

template.php

<div class="content">
    <?php
        echo $content;
    ?>
</div>
4

1 回答 1

1

在将内容加载到 html 后,您可能需要调用用于在对象上初始化 jquery 的函数,因为它会用新的 html 对象覆盖所有绑定。一直发生在我身上。

像这样的东西:

$(document).ready(function(){
       function initBindings(){
            $('.content .class').click(function(e){

                $.get('site', function(data){
                    $('.content').html(data);
                    initBindings();
                })
                e.preventDefault();

            })
        })
        initBindings();
    }) 
于 2013-10-24T11:33:31.180 回答