Jquery event to fire in ajax loaded content, IE & FF problem

Posted by Sylph on Stack Overflow See other posts from Stack Overflow or by Sylph
Published on 2010-05-27T02:01:15Z Indexed on 2010/05/27 2:11 UTC
Read the original article Hit count: 419

Filed under:
|
|
|

Hello,

I'm trying to trigger onclick events in an ajax loaded content but it doesn't seem to work.

Here is my code :-

<li><a href="#" id="subtopic">Title</a></li>
<script type="text/javascript">
   $(function() {
        $("#subtopic").click(function() {
         url: test.html
         ,success: function(data) {
          $('#result').html(data);
          $(".filetree").treeview();
          $('#result').click();
          $('#result').trigger("update");
               }
              });
           });
      });
  </script>

In my loaded content, :-

<a href="#" id="addSubTopic">Click here</a>
  <script type="text/javascript">
      $(document).ready(function() {
          alert("000");
          });
    $(function() {
        $("#addSubTopic").click(function() {
          alert("0");    
          $.ajax({
          url: url,
          success: function(data) {      
           $("#listRes").append(data);      
          }      
         });
      });
     });
 </script>

In IE, it works fine, the click works and I can get the "alert" but in Firefox, the whole thing just go dead. However, my jquery plugin for $(".filetree").treeview(); works fine for both IE and FF. Any advice? I have tried using .live, .trigger("update"). Thanks in advance

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery