Search code examples
jqueryjquery-uijquery-ui-draggablejquery-resizable

Jquery Append div and then make it resizable and draggable?


I'm confused why the script below doesn't work... It appends the div (import_box) and makes it draggable, but not resizable? Am I missing something, I've tried a few different things but they all either disable the dragging or do nothing to improve the situation. I'd be happy for any help...

function open_import_window(){
$('body').append('<div id="msg_bg"></div>');
$('body').append('<div id="import_box" class="import_box"><div class="title_bar">Import</div><div id="content_import_box"></div></div>');
$('#import_box').draggable({handle:".title_bar"}).resizable();
var window_width = $(window).innerWidth();
var import_box_left = (window_width/2)-400;
$("#import_box").css("left", import_box_left);

var window_height = $(window).innerHeight();
var import_box_top = (window_height/2)-250;
$("#import_box").css("top", import_box_top);

$.ajax({
    url: 'import.php',
    success: function(data) {
        $('#content_import_box').html(data);
        resize();
    }
});
}

I made a small jsfiddle: http://jsfiddle.net/YSs6U/


Solution

  • Yes. you're missing the jQuery UI CSS. See this fiddle, check the 'Add Resources' button on the left for the link to (one) jQuery UI CSS theme.