在gridstack.js中,拖动功能无效

时间:2017-01-25 07:44:54

标签: javascript jquery html apex gridstack

我在代码下方使用GridStack.JS(基本结构)

<div class="grid grid-stack">
<div class="grid-item cards grid-stack-item" data-gs-width="4" data-gs-height="2">
    <div class="inner-grid">
    </div>
</div>
<div class="grid-item cards grid-stack-item" data-gs-width="4" data-gs-height="2">
    <div class="inner-grid">
    </div>
</div>
<div class="grid-item cards grid-stack-item" data-gs-width="4" data-gs-height="2">
    <div class="inner-grid">
    </div>
</div>
<div class="grid-item cards grid-stack-item" data-gs-width="4" data-gs-height="2">
    <div class="inner-grid">
    </div>
</div>
<div class="grid-item cards grid-stack-item" data-gs-width="4" data-gs-height="2">
    <div class="inner-grid">
    </div>
</div>
<div class="grid-item cards grid-stack-item" data-gs-width="4" data-gs-height="2">
    <div class="inner-grid">
    </div>
</div>
<div class="grid-item cards grid-stack-item" data-gs-width="4" data-gs-height="2">
    <div class="inner-grid">
    </div>
</div>
<div class="grid-item cards grid-stack-item" data-gs-width="4" data-gs-height="2">
    <div class="inner-grid">
    </div>
</div>

脚本在

下面
<script type="text/javascript">
    $(function () {
        var options = {
            cellHeight: 80,
            verticalMargin: 10,
            columns: 14,
            acceptWidgets: '.',    
            animate: true,
            handle: '.draghandle',
            float: true,
            draggable: {handle: '.-content', scroll: true, appendTo:    'body'},

        };
        $('.grid-stack').gridstack(options);
    });

我这里有2个问题  1.我无法使网格堆栈项目能够被拖动。有人能帮我吗?  2.其次,我无法缩放grid-stack-item容器以增加其高度以匹配内容

任何帮助都将受到极大的赞赏 如果需要,我还可以提供更多清晰度

由于

1 个答案:

答案 0 :(得分:2)

1)您正在指定标记中不存在的拖动句柄.-content

2)Gridstack项目显然具有固定的宽度和高度,因为它们是矩阵,如果您希望项目具有更高的高度,则必须通过data-gs-height="x"

明确指定它