您不能只是将drag_drop_prep中的代码放入一个函数中,然后从application.html.erb和每个部分中调用该函数吗?我猜我误会了。
function prepdraggables(){ // declare all DOM elements with class draggable to be draggable $( ".draggable" ).draggable( { revert : 'invalid' }); // declare all DOM elements with class legal to be droppable $(".legal").droppable({ hoverClass : 'legal_hover', drop : function(event, ui) { var c = new Object(); c['die'] = ui.draggable.attr("id"); c['cell'] = $(this).attr("id"); c['authenticity_token'] = enpreURIComponent(window._token); $.ajax({ type: "POST", url: "/placeDie", data: c, timeout: 5000 }); }});}
在application.html.erb和undo.js.erb中:
prepdraggables();
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)