使用Scriptaculous拖放来防止JavaScript点击事件 [英] Preventing JavaScript click event with Scriptaculous drag and drop

查看:131
本文介绍了使用Scriptaculous拖放来防止JavaScript点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上有一些可拖动的元素。这些相同的元素具有导航到另一页面的点击事件。如果用户正在拖动,我试图确定防止点击事件触发的最佳方法,但仍然允许点击事件(如果不拖动)。任何人都有什么想法可以实现这个最好的方法?

I have some elements on a page which are draggable. These same elements have a click event which navigates to another page. I'm trying to determine the best way of preventing the click event from firing if the user is dragging but still allow the click event if not dragging. Anyone have any ideas of the best way to accomplish this?

推荐答案

我通过使用以下内容解决了这个问题: >

I solved this by using something like the following:

new Draggable('id', {
    onStart: function() {
        dPhoto = $('id');
        Event.stopObserving('id', 'click');
    },
    onEnd : function() {
        setTimeout("Event.observe('id', 'click', function() { location.href = 'url'; });", 500);
    },
    revert: true
});

这篇关于使用Scriptaculous拖放来防止JavaScript点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆