Click here to Skip to main content
15,742,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm building a private chat application using signalr and knockout js. I am able to list currently login users and i need to pop up a chat box when listed username is clicked.

What I have tried:

My pop up script looks like this

function register_popup(id, name) {

           for (var iii = 0; iii < popups.length; iii++) {
               //already registered. Bring it to front.
               if (id == popups[iii]) {
                   Array.remove(popups, iii);




           var element = '<div class="popup-box chat-popup" id="' + id + '">';
           element = element + '<div class="popup-head">';
           element = element + '<div class="popup-head-left">' + name + '</div>';
           element = element + '<div class="popup-head-right"><a href="javascript:close_popup(\'' + id + '\');">✕</a></div>';
           element = element + '<div style="clear: both"></div></div><div class="popup-messages"></div></div>';

           document.getElementsByTagName("body")[0].innerHTML = document.getElementsByTagName("body")[0].innerHTML + element;




My html to list users looks like this

    <ul class="sidebar-name">
        <li data-bind="foreach: users">

            <a href="javascript:register_popup('qblock', data-bind=" text name");">
                <img width="30" height="30" src="my_images_path">
                <span data-bind="text: name"></span>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900