开发者

Jquery drag-n-drop

开发者 https://www.devze.com 2023-02-17 18:22 出处:网络
I have this script, which to display window on screen: $.ajax({ type: \"POST\", url: \"test.php\", data: dataString,

I have this script, which to display window on screen:

$.ajax({
  type: "POST",
  url: "test.php",
  data: dataString,
  cache: false,
  success: function(html){
     $("#work-window").append(html);
  }
});

This window:

<div id="div-add" class="window">
<table cellspacing="0" cellpadding="0" class="top-bar">
<td class="left"></td>
<td cla开发者_开发知识库ss="center">Add</td>
<td class="close"> <span id="develop-link-close">close</span></td>
<td class="right"></td>
</table>
Content
</div>

I need to do, that when click a center class, i can drag and drop this div (#div-add).

i tried make it with jquery Ul, but no result :(

$(function() {
    $( "#div-add" ).draggable();
});

How create this ?


Posting it as an answer here in case it helps anyone else

You're probably making the .draggable() call in your page before #div-add actually exists. Since #div-add exists only after the ajax call, you need to make the $( "#div-add" ).draggable(); call once your AJAX call has completed.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号