删除后,div在jQuery中调整大小

时间:2012-01-11 06:49:41

标签: jquery

我从窗口小部件中删除了一个元素并将其拖动到目标中。像这样:

  jQuery('.ui-layout-center').droppable({
    activeClass: 'ui-state-hover',
    accept:  '.item-art',
    revert: true,
    drop:  function (event, ui) {
      var $canvas = jQuery(this);
      if(!ui.draggable.hasClass('canvas-element')) {
        var $canvasElement = ui.draggable.clone();
        $canvasElement.addClass('canvas-element');
        $canvasElement.html('<div><TEXTAREA COLS=2 ROWS=1></TEXTAREA></div>');
        $canvas.append($canvasElement);
        $canvasElement.css({
          left: (ui.position.left - $canvas.offset().left),
          top: (ui.position.top - $canvas.offset().top),
          position: 'absolute'
        });
        $canvasElement.draggable({
          cursor: 'move'
        });

丢弃后,项目(div)应该可以调整大小。为此我在行$canvasElement.draggable中使用了resizable:

$ canvasElement.resizable()。拖动({           光标:'移动'         });

但它仍然不起作用。用户无法调整已删除的div的大小。请帮帮我。

1 个答案:

答案 0 :(得分:1)

$canvasElement.resizable();

之前添加语句$canvas.append($canvasElement);