views:

24

answers:

2

The project that I am working on dynamically generates tables with jquery's apend(). the problem I am running into is applying interactions to it, they don't affect the generated tables.

The javascript calling the jquery interactions:

$(function() {
    $( '.window' )
        .draggable({ containment: '#desktop', scroll: false, opacity: 0.6, handle:'.winTitle' })
        .resizable({ minHeight: 24, minWidth: 75, helper: 'win-resizable-outline' });
});

The javascript generating the tables:

function dispWindow(cid) {
$('#desktop').append('<table class="window" id="window' + cid +'"><tr><td class="winIcon" id="winIcon' + cid + '"></td><td class="winTitle" id="winTitle' + cid + '"></td><td class="winTR"></td></tr><tr><td class="winL"></td><td class="winBody" id="winBody' + cid + '"></td><td class="winR"></td></tr><tr><td class="winBL"></td><td class="winB"></td><td class="winBR"></td></tr></table>')
}

The call to create a table:

ondblclick="dispWindow('1')"

Any help

A: 

Try establishing draggable and resizable inside dispWindow(), after you've appended the table element.

Thomas
Srry, comments got flipped. Code would be helpful, but good idea
Codeman862
A: 

You could use jQuery's Live and Draggable/Resizable together, as illustrated here.

Example:

$(function() {
    $('.window').live("mouseover", function() {
        if (!$(this).data("init")) {
            $(this).data("init", true);
            $(this).draggable({ containment: '#desktop', scroll: false, opacity: 0.6, handle:'.winTitle' });
        }
    });
});
Doc Hoffiday
Srry, comments got flipped. Thanks, Worked awsomely!
Codeman862