jquery在点击另一个时开始拖动对象 [英] jquery start dragging object when clicked on the other

查看:63
本文介绍了jquery在点击另一个时开始拖动对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是交易:

我正在尝试使用Photoshop中的颜色选择器,因此我有一个颜色选择器的背景图像(彩虹般的图像200x200 px)和内部的圆形触发器。

I'm trying to make a colorpicker act much like in Photoshop, so I have a background image of a color picker (rainbow-like image 200x200 px) and a circle trigger inside of it.

因此,如果我将可拖动的UI附加到圆圈:

So, if i attach a draggable UI to a circle:

$('#rainbow-color-picker .circle').draggable({containment: 'parent'});

效果很好。但这是另一个问题..当我点击圆圈的父块(即颜色选择器图像)时,我希望拖动开始。

Works great. But here's another issue.. I want the drag to start when I click the parent block of the circle (i.e. the color picker image).

这是HTML标记:

<div class='rainbow-color-picker' id='rainbow-color-picker'><div class='inner1'><div class='inner2'>
 <div class='circle'><div class='circle-inner'></div></div>
</div></div></div>

所以当我点击.inner2时,我想要.circle开始拖动。

So when I click on .inner2, I want .circle to start dragging.

我试过

$("#rainbow-color-picker .inner2").bind( "mousedown", function(event) {  
  $("#rainbow-color-picker .circle").trigger('dragstart');  
});

但这不起作用:(有没有人碰巧遇到这个问题?

But that doesn't work :( did anyone happen to meet this problem?

谢谢

推荐答案

在这里,它只是想通了。

Here it is, just figured it out.

$(#rainbow-color-picker .circle)。触发器(事件);

这是我的机票:

可点击jquery draggable parent start drag?

这篇关于jquery在点击另一个时开始拖动对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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