【发布时间】:2014-02-16 20:39:21
【问题描述】:
我有以下 html 和 js(查看下面的 jsfiddle)。
我已经准备好将 dom 上的 jquery 拖动事件绑定到 .control-group。
如果用户单击并拖动除输入以外的任何位置(在 div 内),他们可以按预期拖动 div,但如果他们在输入中单击,它会选择文本输入的输入,(并且不允许我们拖动它)。
我希望能够让用户点击 div 中的任何内容,并且应该能够拖动整个 div。
<div class="control-group">
<label class="control-label" for="textInput">Text Input</label>
<div class="controls">
<!-- If someone clicks on this input, the whole div should still be draggable -->
<!-- Its ok if the input is not usable, thats the point!, Its just for show -->
<input id="textInput" name="textInput" type="text" placeholder="placeholder"/>
<p class="help-block">you have an error!</p>
</div>
</div>
jQuery(Dom 就绪):
$('.control-group').draggable();
所以我正在寻找“冒泡”到.control-group div 的事件。 (如果我猜对了?!)
【问题讨论】:
标签: javascript jquery jquery-ui drag-and-drop