开发者

jQuery - Call function when dropping div

I want to run function insertHouse() when dropping div#Draggable. I can't manage to make it work. You can see me trying to call it in the second line from the bottom. What am I doing wrong?

<img src="images/door1.jpg" id="draggable">
<div id="items"></div>

// Place house;
function insertHouse()
{
blablabla
}

$( init );

function init() {
  $('#makeMeDraggable').draggable();
  $('body').droppable( {
    drop: handleDropEvent
  } );
}

function handleDropEvent( event, ui ) {
  function insert开发者_C百科House();
}


Following code will work...

function init() {
  $('#makeMeDraggable').draggable();
  $('body').droppable( {
drop: function(event, ui){
insertHouse();
}
  } );
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜