jQuery 拖/放 - 每个“拖放”的模式都有不同的模式物品?
刚刚回答了我的另一个问题(模态未在下降时打开)。现在我有一个新问题:
$( "#table #food li.corn" ).draggable({ revert: "invalid", hoverClass: "ui-state-active" }); $( "#plate ul" ).droppable({ hoverClass: "ui-state-active", drop: function( event, ui ) { $(this).addClass( "ui-state-highlight" ); $( "#cornDialog" ).dialog( "open" ); } }); $( "#cornDialog" ).dialog({ autoOpen: false, show: "blind", hide: "slow" });
#cornDialog是当玉米片掉落时将打开的模式。 li.corn 是“可拖动”的玉米片,#plate 是“可拖放”的 div,但如您所见,它无法知道哪个元素被拖/放,因此 #cornDialog 将为每个项目打开。我需要一种方法来为每件食物(火鸡腿、苹果等)打开不同的对话框。有道理吗?
Just got my other question answered (modal wasn't opening on drop). Now I have a new problem:
$( "#table #food li.corn" ).draggable({ revert: "invalid", hoverClass: "ui-state-active" }); $( "#plate ul" ).droppable({ hoverClass: "ui-state-active", drop: function( event, ui ) { $(this).addClass( "ui-state-highlight" ); $( "#cornDialog" ).dialog( "open" ); } }); $( "#cornDialog" ).dialog({ autoOpen: false, show: "blind", hide: "slow" });
#cornDialog is the modal that will open when the piece of corn is dropped. li.corn is the piece of corn that's "draggable" and #plate is the div that's "droppable", but as you can see it has no way of knowing which element was being dragged/dropped so the #cornDialog would open for every item. I need a way to get a different dialog to open for each piece of food (turkey leg, apple, etc). Make sense?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将“cornid”的 jQuery 数据属性 添加到每个可拖动的 li.corn 中,您可以执行类似的操作this:
如果您发布有关如何创建“li.corn”的信息,我可以建议如何添加 jQuery 数据属性。
If you add a jQuery data attribute of "cornid" to each draggable li.corn you can do something like this:
If you post information about how you create your "li.corn"s I can advise about how to add the jQuery data attribute.