Hi everybody,
I am using $.post to add new group name to DB and show newly created group to the user. Here is the code:
- $('#new_group').click(function(){
- var name = $("#group_name").val();
- $.post("/async/addgroup",{
- "name" : name
- }, function(response){
- var id = response;
- var echo_str = $("<div id='group_"+id+"'><strong>Name:</strong> <div class='editgroup' id='"+id+"'>"+name+"</div><a href='#' class='clickeditgroup'>Edit</a> | <a href='#' id='"+id+"' class='deletegroup'>Delete</a></div>");
- $("#group_names").prepend(echo_str.hide().fadeIn());
- $("#group_name").val("");
- });
-
- return false;
- });
this work well, but when the new div is created (fadedIn) I am not able to click the edit and delete button. I have to refresh the page to make them work.
Here is the code for deleting group
- $('.deletegroup').bind('click',function(){
- var id = $(this).attr('id');
-
- $('#group_'+id).fadeOut(1000,function(){
- $('#group_'+id).remove();
- });
- return false;
- });
I have compared the HTML code before and after reloading page and it is the same.
I am really confused. Any Ideas?
Any help would be much appreciated.
P.