[問題] 請問jQuery的Draggable問題

看板Ajax作者 (I have a dream...)時間14年前 (2011/03/09 11:57), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/1
我參考 http://jqueryui.com/demos/draggable/#default 使用拖曳的功能 可是當我製作個按鈕新增區塊時, 為何新的區塊沒法拖曳呢? 請問該如何改善?實在感謝~ $(function() { $( "#draggable" ).draggable(); $( "#draggable2" ).draggable(); $('#addbox').click(function() { var $newbox = $("<div id='draggable2' class='ui-widget-content'><p>Drag me around</p></div>"); $("div.demo").append($newbox); }); }); <body> <div style="height:50px "><input type="button" value="新增空位" id="addbox"/></div> <div class="demo"> <div id="draggable" class="ui-widget-content"> <p>Drag me around</p> </div> </div> <body> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 192.83.191.166

03/09 12:08, , 1F
時間點問題,新的content 沒有被call到 draggable.
03/09 12:08, 1F

03/09 12:08, , 2F
你的寫法只有在document ready存在的資料會call draggable
03/09 12:08, 2F

03/09 12:48, , 3F
感謝提點~我將click觸發時再call一次draggable就可以用了^^
03/09 12:48, 3F
文章代碼(AID): #1DTlgW3B (Ajax)
文章代碼(AID): #1DTlgW3B (Ajax)