0

I am making sample chat application using signal R but my keyup event is getting dead.I have used clone This is my sample code

//keypress event of textbbox here..
            $(".ChatText").live('keyup', function () {
                if($(".ChatText").val().length > 0)
                {
                alert('test');
                   var messsage_typing=$("#hdnUserName").val() + " is typing...";
                   var strGroupName = $(this).parent().attr('groupname');
                    if (typeof strGroupName !== 'undefined' && strGroupName !== false)
                        chat.server.send($("#hdnUserName").val() + ' : ' + messsage_typing, $(this).parent().attr('groupname'),"1");

                }
            });
            //end of keypress

and this is the code of my add message in which i have

 chat.client.addMessage = function (message, groupName,recievername,imagetag,Istypingmessage) {

            if ($('div[groupname=' + groupName + ']').length == 0) {
                var chatWindow = $("#divChatWindow").clone(true);
                //also tried this not working 
                //var chatWindow = $("#divChatWindow").clone(true,true);
                $(chatWindow).css('display', 'block');
                $(chatWindow).attr('groupname', groupName);

                $("#chatContainer").append(chatWindow);
                //buggy code do not delete..
                //remove all previous li
                $('div[groupname=' + groupName + ']').find('ul li').remove();
                //replace header tag with new name
                $('div[groupname=' + groupName + ']').find('a').html(recievername);

                $("#chatContainer").draggable();
                $("#chatContainer").css('cursor','move');
            }

Please help me out to bind my keyup events here.. Thanks

Rajubhai
  • 107
  • 4
  • 13

1 Answers1

1

Try cloning a deep copy of the element

var clone = $('.hello').clone(true);

http://api.jquery.com/clone/#clone-withDataAndEvents

Lisa Young
  • 240
  • 1
  • 4
  • 10