[英]How can I call click event when drag and drop event
I want change event drag and drop, to click event for my objects. 我想要拖放事件,以单击对象的事件。 I try this code 我尝试这段代码
$("a").draggable({
start: function (event, ui) {
$(this).trigger("click");
}
});
But not work :( 但不起作用:(
UPDATE: 更新:
I try this code: 我尝试以下代码:
document.ondragstart = function () {
return false;
};
document.onmouseup = function (a, b) {
$(this).trigger("click");
};
But trigger click still not work 但是触发点击仍然不起作用
Try with this modification: 尝试进行此修改:
$("a").draggable({
start: function (event, ui) {
$(--your-button-element-here-).click();
}
});
I found just such a solution 我发现了这样的解决方案
var url = null;
$("a").mousedown(function () {
url = $(this).attr("href");
$(window).mousemove(function () {
$(window).unbind("mousemove");
});
});
$(window).mouseup(function () {
$(window).unbind("mousemove");
if (url != null) {
location.href = url;
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.