javascript - 在引导可排序元素内映射 - 停止拖动
问题描述
我有由 Bootstrap 可排序插件(x_panels)处理的元素,在其中一个中,有一个包含地图的元素。地图是通过拖动来操作的,就像可排序的元素一样。因此,当我尝试拖动地图时,会触发 sortable 的 start 事件并移动整个面板。我的问题是在地图内拖动时如何防止排序?我试图让面板容器成为一个句柄,但它根本不起作用。我还尝试将处理程序附加到地图上的事件mousedown
和事件,但它也没有帮助。dragstart
preventDefault()
stopPropagation()
任何想法如何处理这个?
容器 HTML:
<div id="widget-container" class="row">
<div class="col-xs-12 col-sm-6 widget-holder" id="x17">
<div class="x_panel">
<div class="x_title">
<h2><i class="fa fa-area-chart"></i> Title
<small id="date-from-to">
</small>
</h2>
<ul class="nav navbar-right panel_toolbox" style="min-width: auto">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="modal" data-target="#modal-filter-{$data->id_widget_person}" role="button" aria-expanded="false">
<i class="fa fa-calendar"></i>
</a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
<!-- This is the map container -->
<div id="map-container" class="gmap"></div>
</div>
</div>
</div>
</div>
#widget_container
包含所有可排序的元素。
可排序处理程序:
$("#widget-container").sortable({
containerSelector: "#widget-container",
itemSelector: ".widget-holder",
placeholder: "col-sm-3 widget-placeholder",
start: function(e, ui) {
ui.placeholder.height(ui.item.height);
ui.placeholder.width(ui.item.width);
},
stop: function (event, ui) {
var data = $("#widget-container").sortable("toArray");
console.log(data);
$.ajax({
type: 'POST',
url: '/url.php',
data: {
data: data
},
success: function(res) {
}
});
}
}).disableSelection();
解决方案
我已经通过制作一个具有 100% 面板宽度的手柄来整理它x_title
,所以我只能通过抓住面板的上部来移动面板,这对我来说完全足够了。如果您对此特定问题仍有答案,请随时发布。
推荐阅读
- javascript - 创建 React App 无法解析本地文件
- splunk - 下拉列表中的索引器分组
- javascript - 如何在浏览器之间传递会话?
- c# - 在不影响 Selected 和 Focused 基本外观的情况下更改 DataGridCell 前景
- swift - 如何在没有第三方框架的情况下正确初始化 ViewController 中的 Codable 结构?
- python - 使用回溯和递归找到允许在迷宫中破墙的老鼠的最短路径。我的代码有什么问题?
- url - 无法从公司 VPN 浏览托管在 EC2 上的公共 URL?
- linux - Triggering long running operations from within a Linux ISR
- python - 增加子图的 y 刻度标签时 matplotlib 轴标签丢失
- c - Getting variable size in C preprocessor