Search code examples
jqueryjquery-ui-resizablejquery-ui-sortable

dynamically resizable div jquery


my Proplem is when i creat div use

var toprint= "<div id='any' class ="resizable sort">content</div> <div id='any2' class ="resizable darg">content</div> ";

then add to page use this code

$(ui.item).html(toprint);

it be sortable only not resizable too

$('.sort').sortable({  
    handle:'.widget-head', 
    connectWith: ".sort", 
    out: function (e,ui) { 
        $(".sort").children().resizable({ 
            axis: 'x', 
            containment: 'parent', 
            resize: function(event, ui)  { 
                ui.size.width = ui.originalSize.width; 
                (ui.helper).css({'position': '', 'top': '0px'}); 
            } 
        }); 
    }  
}); 

Solution

  • Try this it might work.

     $('.sort').live('click', function() {
        $(function() {
            $('.sort).children().resizable({
                axis: 'x', 
                containment: 'parent', 
                resize: function(event, ui)  { 
                    ui.size.width = ui.originalSize.width; 
                    (ui.helper).css({'position': '', 'top': '0px'}); 
                });
            });
        });
    });