views:

24

answers:

0

I am trying to bind the dialog initiation (which happens in document ready) to a live or delegate for a div. Something like this for click event:

    $("#divSelectedContacts").delegate("span", "hover", function () { 
              $(this).toggleClass("strikeOut"); 
     });

for this:

 $("#divContacts").dialog('destroy').dialog({
            bgiframe: true,
            resizable: false,
            autoOpen: false,
            height: 600,
            width: 425,
            modal: true,
            overlay: {
                backgroundColor: '#000',
                opacity: 0.5
            },
            buttons: {
                Cancel: function () {
                    //basically do nothing
                    $(this).dialog("close");
                },
                'Done': function () {
                    //get all the selected ppl and store it in To
                    //alert($("#divSelectedContacts").html());
                    $("#divTo").empty().html($("#divSelectedContacts").html());
                    $(this).dialog("close");
                }

            }
        });

Is this possible to use delegate for this so that it is bound forever? The main problem is I dynamically load the html in one of the tabs and when I include the dialog script in the HTML then it creates multiple dialogs and does not work. Any help is much appreciated.

Thanks in advance.