Bootstrap 3列类干扰jquery-ui droppable div

鲍勃

我使用jQuery-UI v1.11.2来创建一些可拖动和可拖放的div,以及Boostrap 3.1.1。

我想知道为什么Boostrap列类会干扰可拖动的“提示”。

换句话说,当我将图像从Gallery div拖动到Dashboard div时,Dashboard div出现在图像提示的前面。然后,一旦我在Dashboard div上删除我的图像,该图像就会重新出现。

如果我从仪表板div中删除col-md-8类,则此问题将消失。

这是两个屏幕快照,以演示:

1)在右侧div上没有Bootstrap列类(图像提示看起来不错)

2)在右侧div上使用Bootstrap列类(图像提示消失)

没有Bootstrap列类的良好可拖动提示

Bootstrap列类的可拖动提示不正确

这是HTML代码:

<section id="gadgets-view" class="mainbar" data-ng-controller="gadgets">

<div class="container-fluid">                       
    <div class="row-fluid">
        <!-- based on http://jqueryui.com/droppable/#photo-manager -->
        <div class="ui-widget ui-helper-clearfix  col-md-4">    <-- GALLERY OF WIDGETS -->
            <ul id="gallery" class="gallery ui-helper-reset ui-helper-clearfix">
                <li class="ui-widget-content ui-corner-tr">
                    <h5 class="ui-widget-header">Tree Grid</h5>                    
                    <img src="images/treegrid.jpg" alt="Hierarchy Grid" width="96" height="72">
                </li>
                <li class="ui-widget-content ui-corner-tr">
                    <h5 class="ui-widget-header">Area Chart</h5>
                    <img src="images/chart_area.jpg" alt="Area Chart" width="96" height="72">

                </li>
                <li class="ui-widget-content ui-corner-tr">
                    <h5 class="ui-widget-header">Bar Chart</h5>
                    <img src="images/chart_bar.png" alt="Bar Chart" width="96" height="72">                    
                </li>
                <li class="ui-widget-content ui-corner-tr">
                    <h5 class="ui-widget-header">Column Chart</h5>
                    <img src="images/chart_column.png" alt="Column  Chart" width="96" height="72">                        
                    <a href="link/to/dashboard/script/when/we/have/js/off" title="Add this gadget" class="ui-icon ui-icon-plus"></a>
                </li>
                <li class="ui-widget-content ui-corner-tr">
                    <h5 class="ui-widget-header">Line Chart</h5>
                    <img src="images/chart_line.png" alt="Line  Chart" width="96" height="72">

                </li>
            </ul>                
        </div>
        <div class="col-md-8">
            <div id="dashboard" class="ui-widget-content ui-state-default  ">   <-- DROPPABLE DASHBOARD -->
                <h4 class=""><span class="ui-icon ui-icon-image"></span>Dashboard</h4>
            </div>
        <div>
    </div>
</div>
</section>

CSS:

<style>    
.ui-widget-header{
    font-size: 65%;
    font-family: "Trebuchet MS", "Helvetica", "Arial", "Verdana", "sans-serif";      
}
.ui-state-highlight {
    border: 2px dashed #d3d3d3;  /* override to show dashed border when dragging */
}
#gallery {
    float: left;
    width: 75%;
    min-height: 12em;
}

.gallery.custom-state-active {
    background: #eee;
}

.gallery li {
    list-style: none;
    float: left;
    width: 96px;
    padding: 0.4em;
    margin: 0 0.4em 0.4em 0;
    text-align: center;
}

    .gallery li h5 {
        margin: 0 0 0.4em;
        cursor: move;
    }

    .gallery li a {
        float: right;
    }

        .gallery li a.ui-icon-zoomin {
            float: left;
        }

    .gallery li img {
        width: 100%;
        cursor: move;
    }

#dashboard {
    float: left;
    width: 45%;
    height:500px;
    padding: 1%;
}

    #dashboard h4 {
        line-height: 25px;
        margin: 0 0 0.4em;
    }

        #dashboard h4 .ui-icon {
            float: left;
        }

    #dashboard .gallery h5 {
        display: none;
    }

创建拖放区域的JavaScript:

<script>
$(function () {
    // there's the gallery and the dashboard
    var $gallery = $("#gallery"),
      $dashboard = $("#dashboard");

    // let the gallery items be draggable
    $("li", $gallery).draggable({
        cancel: "a.ui-icon", // clicking an icon won't initiate dragging
        revert: "invalid", // when not dropped, the item will revert back to its initial position
        containment: "document",
        helper: "clone",
        cursor: "move"
    });

    // let the dashboard be droppable, accepting the gallery items
    $dashboard.droppable({
        accept: "#gallery > li",
        activeClass: "ui-state-highlight",
        drop: function (event, ui) {
            debugger;
            deleteImage(ui.draggable);
        }
    });

    // let the gallery be droppable as well, accepting items from the dashboard
    $gallery.droppable({
        accept: "#dashboard li",
        activeClass: "custom-state-active",
        drop: function (event, ui) {
            recycleImage(ui.draggable);
        }
    });

    // image deletion function
    var recycle_icon = "<a href='link/to/recycle/script/when/we/have/js/off' title='Remove gadget' class='ui-icon ui-icon-minus'></a>";
    function deleteImage($item) {
        $item.fadeOut(function () {
            var $list = $("ul", $dashboard).length ?
              $("ul", $dashboard) :
              $("<ul class='gallery ui-helper-reset'/>").appendTo($dashboard);

            //$item.find("a.ui-icon-dashboard").remove();   // DO NOT REMOVE ORIGINAL WIDGET ICON - 11/19/2014 BM:
            $item.append(recycle_icon).appendTo($list).fadeIn(function () {
                //$item.animate({ width: "48px" }).find("img").animate({ height: "36px" });
                $item.animate().find("img").animate();
            });
        });
    }

    // image recycle function
    var dashboard_icon = "<a href='link/to/dashboard/script/when/we/have/js/off' title='Add this gadget' class='ui-icon ui-icon-plus'</a>";
    function recycleImage($item) {
        $item.fadeOut(function () {
            $item
              .find("a.ui-icon-refresh")
                .remove()
              .end()
              .css("width", "96px")
              .append(dashboard_icon)
              .find("img")
                .css("height", "72px")
              .end()
              .appendTo($gallery)
              .fadeIn();
        });
    }

    // image preview function, demonstrating the ui.dialog used as a modal window
    function viewLargerImage($link) {
        var src = $link.attr("href"),
          title = $link.siblings("img").attr("alt"),
          $modal = $("img[src$='" + src + "']");

        if ($modal.length) {
            $modal.dialog("open");
        } else {
            var img = $("<img alt='" + title + "' width='384' height='288' style='display: none; padding: 8px;' />")
              .attr("src", src).appendTo("body");
            setTimeout(function () {
                img.dialog({
                    title: title,
                    width: 400,
                    modal: true
                });
            }, 1);
        }
    }

    // resolve the icons behavior with event delegation
    $("ul.gallery > li").click(function (event) {
        var $item = $(this),
          $target = $(event.target);

        if ($target.is("a.ui-icon-dashboard")) {
            deleteImage($item);
        } else if ($target.is("a.ui-icon-zoomin")) {
            viewLargerImage($target);
        } else if ($target.is("a.ui-icon-refresh")) {
            recycleImage($item);
        }

        return false;
    });
});

巴斯·乔布森

我找到了您描述的问题(但是我没有找到与Bootstrap Grid Classs的关系)。

对我来说,问题似乎与z-index有关,可以通过在CSS代码末尾添加以下样式规则来解决:

.ui-draggable-handle {
z-index: 1;
}   

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

jQuery UI Draggable on droppable元素

来自分类Dev

带有Bootstrap Navbar的jQuery UI Droppable-如何在Dropdown中放置项目

来自分类Dev

使用Jquery ui Droppable将元素直接插入div

来自分类Dev

jQuery UI Droppable排除特定划分

来自分类Dev

日历的jQuery UI Droppable和Draggable

来自分类Dev

jQuery UI Droppable不接受事件

来自分类Dev

没有可重复的jQuery UI Droppable

来自分类Dev

动态使用droppable函数-jQuery UI

来自分类Dev

jQuery UI Droppable仅接受来自某些类的拖放

来自分类Dev

jQuery UI Droppable仅接受来自某些类的拖放

来自分类Dev

当拖放到Jquery ui中的droppable div中时,为什么可拖动元素的克隆正在还原?

来自分类Dev

在jQuery-ui droppable中检测不可接受的拖放

来自分类Dev

jQuery UI Droppable and Sortable-放置在正确的排序位置

来自分类Dev

动态添加元素上的jQuery UI droppable吗?

来自分类Dev

jQuery UI Droppable在out:函数上无法按预期工作

来自分类Dev

jQuery UI Droppable and Sortable-放置在正确的排序位置

来自分类Dev

在jQuery UI中放置Droppable之后将Draggable元素居中

来自分类Dev

jQuery UI droppable的hoverClass无法在移动设备中触发

来自分类Dev

动态添加元素上的jQuery UI droppable吗?

来自分类Dev

jQuery UI Droppable在out:函数上无法按预期工作

来自分类Dev

JQuery UI droppable draggable HTML 在多次拖放后损坏

来自分类Dev

如何在jQuery UI中使用Draggable和Droppable将拖放的li附加到droppable ui中?

来自分类Dev

如何在jQuery UI中使用Draggable和Droppable将拖动的li附加到droppable ui中?

来自分类Dev

Dynamically added div as droppable, ng-repeat and Jquery

来自分类Dev

动态添加div作为droppable,ng-repeat和Jquery

来自分类Dev

jQuery动态div添加具有droppable属性

来自分类Dev

jQuery UI(Droppable):如果droppable具有相对/绝对的css位置,则可拖动元素未放置在鼠标指针上

来自分类Dev

当使用jquery-ui droppable时,如何在将其删除后如何将其从droppable区域中删除?

来自分类Dev

滚动div中重叠的Droppable

Related 相关文章

  1. 1

    jQuery UI Draggable on droppable元素

  2. 2

    带有Bootstrap Navbar的jQuery UI Droppable-如何在Dropdown中放置项目

  3. 3

    使用Jquery ui Droppable将元素直接插入div

  4. 4

    jQuery UI Droppable排除特定划分

  5. 5

    日历的jQuery UI Droppable和Draggable

  6. 6

    jQuery UI Droppable不接受事件

  7. 7

    没有可重复的jQuery UI Droppable

  8. 8

    动态使用droppable函数-jQuery UI

  9. 9

    jQuery UI Droppable仅接受来自某些类的拖放

  10. 10

    jQuery UI Droppable仅接受来自某些类的拖放

  11. 11

    当拖放到Jquery ui中的droppable div中时,为什么可拖动元素的克隆正在还原?

  12. 12

    在jQuery-ui droppable中检测不可接受的拖放

  13. 13

    jQuery UI Droppable and Sortable-放置在正确的排序位置

  14. 14

    动态添加元素上的jQuery UI droppable吗?

  15. 15

    jQuery UI Droppable在out:函数上无法按预期工作

  16. 16

    jQuery UI Droppable and Sortable-放置在正确的排序位置

  17. 17

    在jQuery UI中放置Droppable之后将Draggable元素居中

  18. 18

    jQuery UI droppable的hoverClass无法在移动设备中触发

  19. 19

    动态添加元素上的jQuery UI droppable吗?

  20. 20

    jQuery UI Droppable在out:函数上无法按预期工作

  21. 21

    JQuery UI droppable draggable HTML 在多次拖放后损坏

  22. 22

    如何在jQuery UI中使用Draggable和Droppable将拖放的li附加到droppable ui中?

  23. 23

    如何在jQuery UI中使用Draggable和Droppable将拖动的li附加到droppable ui中?

  24. 24

    Dynamically added div as droppable, ng-repeat and Jquery

  25. 25

    动态添加div作为droppable,ng-repeat和Jquery

  26. 26

    jQuery动态div添加具有droppable属性

  27. 27

    jQuery UI(Droppable):如果droppable具有相对/绝对的css位置,则可拖动元素未放置在鼠标指针上

  28. 28

    当使用jquery-ui droppable时,如何在将其删除后如何将其从droppable区域中删除?

  29. 29

    滚动div中重叠的Droppable

热门标签

归档