jQuery拖放模拟插件(jQuery Drag & Drop Simulate Plugin)
提前谢谢你看看这个! 我无法通过此处的扩展插件模拟jQuery UI提供的拖放功能:
https://github.com/j-ulrich/jquery-simulate-ext/blob/master/doc/drag-n-drop.md
该文档使用我修改的以下内容来满足我的需求:
$('#draggableDiv').simulate("drag", {dragTarget: otherDiv}); Changed to this: $('#placeme').simulate("drag", {dragTarget: $("#page1")});
我的警报消息永远不会弹出,因此很明显drop函数永远不会被触发,我不知道为什么。 手动将对象拖动到page1正常运行。
JSFiddle: http : //jsfiddle.net/d2fdvxhz/8/
HTML:
<div class="container"> <div id="view-port"> <div id="placeme" class="droppableShape"> <img src="https://upload.wikimedia.org/wikipedia/en/6/6f/Smiley_Face.png" width="25" height="25" /> </div> <button id="testme">Simulate Drop</button> <div class="page" id="page1" style="background-image: url(http://images.huffingtonpost.com/2012-08-15-1CanvasPanelInstall5psd.jpg);"></div> <!-- Pages Here --> </div> </div>
JS:
$(document).ready(function(){ $(".droppableShape").draggable({ helper:'clone' }); $(".page").droppable({ accept: ".droppableShape", tolerance: 'fit', drop: function(event,ui){ alert("Drop Detected"); var new_field = $(ui.helper).clone().removeClass('droppableShape'); var droppable_page = $(this); var droppableOffset = $(this).offset(); new_field.css('top', ui.position.top - droppableOffset.top); new_field.css('left', ui.position.left - droppableOffset.left); // Set Draggable Options new_field.draggable({ containment: droppable_page, stop: function(event, ui) { // Save position after dragging stops $(this).data("x_cord", ui.position.left); $(this).data("y_cord", ui.position.top); $(this).draggable( "disable" ); } }); // Add to drop area $(this).append(new_field); } }); $( "#testme" ).click(function() { $('#placeme').simulate("drag", { dragTarget: $("#page1") }); console.log("Simulate Attempted"); }); });
Thank you in advance for taking a look at this! I am having trouble simulating the drag & drop feature provided by jQuery UI via the extended plugin found here:
https://github.com/j-ulrich/jquery-simulate-ext/blob/master/doc/drag-n-drop.md
The documentation uses the following to which I modified to suite my needs:
$('#draggableDiv').simulate("drag", {dragTarget: otherDiv}); Changed to this: $('#placeme').simulate("drag", {dragTarget: $("#page1")});
My alert message never pops up, therefore it is evident that the drop function is never fired, I'm not sure why. Manually dragging the object to page1 behaves normally.
JSFiddle: http://jsfiddle.net/d2fdvxhz/8/
HTML:
<div class="container"> <div id="view-port"> <div id="placeme" class="droppableShape"> <img src="https://upload.wikimedia.org/wikipedia/en/6/6f/Smiley_Face.png" width="25" height="25" /> </div> <button id="testme">Simulate Drop</button> <div class="page" id="page1" style="background-image: url(http://images.huffingtonpost.com/2012-08-15-1CanvasPanelInstall5psd.jpg);"></div> <!-- Pages Here --> </div> </div>
JS:
$(document).ready(function(){ $(".droppableShape").draggable({ helper:'clone' }); $(".page").droppable({ accept: ".droppableShape", tolerance: 'fit', drop: function(event,ui){ alert("Drop Detected"); var new_field = $(ui.helper).clone().removeClass('droppableShape'); var droppable_page = $(this); var droppableOffset = $(this).offset(); new_field.css('top', ui.position.top - droppableOffset.top); new_field.css('left', ui.position.left - droppableOffset.left); // Set Draggable Options new_field.draggable({ containment: droppable_page, stop: function(event, ui) { // Save position after dragging stops $(this).data("x_cord", ui.position.left); $(this).data("y_cord", ui.position.top); $(this).draggable( "disable" ); } }); // Add to drop area $(this).append(new_field); } }); $( "#testme" ).click(function() { $('#placeme').simulate("drag", { dragTarget: $("#page1") }); console.log("Simulate Attempted"); }); });
原文:https://stackoverflow.com/questions/32892083
最满意答案
使用
dialogClass
将类添加到要显示关闭按钮的ui对话框,然后根据该类添加要显示的css:Add a class using
dialogClass
to the ui dialog you want to show the close button and then add css to show based on that class:
相关问答
更多-
要添加更多按钮,只需在buttons数组中添加'em $( ".dialog" ).dialog({ autoOpen: false, buttons: [ { text: "Help", icon: "ui-icon-help", click: function( e ) { //function ...
-
这是一个GtkButton,带有图标window-close-symbolic带有样式类titlebutton (与标题中其他按钮相同的类),假定应用程序正在使用内置关闭按钮。 It's a GtkButton with icon window-close-symbolic with style class titlebutton (the same class as the other buttons on the header), assuming the app is using the built- ...
-
我想这就是你需要的 HTML:TitleX
-
从jQuery对话框中删除没有十字按钮的标题栏(Remove title bar without the cross button from jQuery Dialog box)[2022-04-28]
一种解决方案可能是创建jQueryUI对话框的第二个实例,并专门针对CSS中的该实例。 jsFiddle演示 CSS将如下所示: [aria-labelledby=ui-id-2].ui-dialog .ui-dialog-titlebar { background:transparent; border:none; } [aria-labelledby=ui-id-2].ui-dialog .ui-dialog-title { display:none; } 在Google Ch ... -
弹出的jquery按钮(jquery button in pop up)[2022-03-28]
为了让一个选择器处理动态添加到页面的项目,我总是将它绑定到这样的文档 $(document).on('click', '#PopupAdd', function(){... Add some event on document.ready function of that page whose button is not working first time like--> This is function for accept numeric values only in textboxes on ke ... -
示例HTML标记:
S.no Text One Text -
JOptionPane内部对话框没有标题栏或关闭按钮?(JOptionPane Internal Dialog without title bar or close button?)[2023-07-01]
您可以使用JDialog类 这是一个例子,试着激发它: import java.awt.FlowLayout; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; public class BDialog extends JDialog { private JButton okBtn = new JButton("OK"); ... -
单击正文关闭弹出窗口(Close pop up by clicking on body)[2021-12-04]
看到这个问题: 当用户点击DIV时,使用jQuery隐藏DIV var mouse_is_inside = false; $(document).ready(function() { $('.form_content').hover(function(){ mouse_is_inside=true; }, function(){ mouse_is_inside=false; }); $("body").mouseup(functio ... -
使用dialogClass将类添加到要显示关闭按钮的ui对话框,然后根据该类添加要显示的css: https://jsfiddle.net/jmcjzkyv/ Add a class using dialogClass to the ui dialog you want to show the close button and then add css to show based on that class: https://jsfiddle.net/jmcjzkyv/
-
这可以被视为快速解决方案。 .ui-dialog-titlebar{background-color:#c2c2c2;} .ui-dialog .ui-dialog-titlebar-close { background-image: url(https://cdnjs.cloudflare.com/ajax/libs/aui/6.0.1/aui/css/icons/aui-icon-close.png); z-index:999999; } 但有时这可能会奏效。 The only problem ...