0

i'd like to use ajax to reload only part of my webpage. The problem after reload is that i lose the 'click' event on the link element

code:

<div id="content1">
    //html/php code to get the action
    if ($action==1) 
        echo '<a class="toggleAction" href="#">activate</a>';
    else echo '<a class="toggleAction" href="#">desactivate</a>';
    //...
    <script type="text/javascript">
        $('.toggleAction').on('click',function (e){
            e.preventDefault();
            e.stopPropagation();
            //getting some parameters..
            $.post('activation.php', {val1:x,val2:y}).done(function(feedback){
                handle(feedback);
         });

        //relaod only #content1                                
        $("#content1").load("index.php #content1");
    </script>
</div>

i had the js script in separate js file and removed it in the html to add the click event every time i reload "#content1". The event works the first time, but doesn't exist after #content1# reload. Any help for this ?

BTW, is there important browser issues when using this instead of usual reloading of the page?

Ben S.
  • 43
  • 5

0 Answers0