Welcome Guest, Not a member yet? Register   Sign In
jQuery e.preventDefault(); stops working after reloading div
#1

[eluser]mojitoo[/eluser]
Hey!

I've have a problem with jquery and codeigniter, e.preventDefault(); stops working after I've reloaded a div with jquery and I've no idea why so I need you're help to find / solve the problem

I add comments with the following code and the reload the div
Code:
addComments: function( comment ) {

   var form_data = {
      comment: comment,
      list_id: list_id,
      ajax: '1'
     };

   $.ajax({
    url: base_url + 'lists/add_new_comment',
    type: 'POST',
    data: form_data,
    dataType : 'json',
    success: function(data) {
     $('#comment_wrapper').load(base_url + 'lists/refresh_comments/' + data.result, function() {
      // reload javascript objects
      Essentials.hasJavaScript();
     });
     // empty outputs that might be left
     $('.comment_msg').html('');
     $('#comment').val('');
    }
   });
  }

And everything seems to be working, the delete link is correct and everything. But e.preventDefault(); doesn't work any longer
Code:
$('.delete_comment').on('click', function(e){

  e.preventDefault();

Why? Please help me solving this annoying bug. This works if I press delete before I make a comment.


Messages In This Thread
jQuery e.preventDefault(); stops working after reloading div - by El Forum - 05-01-2012, 08:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB