如何使网格自动移动的小部件停止向上

How to make gridstack auto widgets moving stop towards upward?

本文关键字:小部 网格 何使 移动      更新时间:2023-09-26

希望gridstack团队身体健康!我只是想能够,当我移动一个小部件,所以其他小部件不向上的方向去填补它的空白的地方…!相反,当我移动一个小部件时,我更希望其他小部件留在它们的位置,而不是向上填充新移动的小部件位置…!我要怎么做呢?有人能告诉我吗?我试着到处检查和搜索,但要么没有得到它,要么没有得到它如何使它工作…!

 <script type="text/javascript">
 var jq=jQuery.noConflict();
    jq(document).ready(function (e) {
    jq('.upload').on('submit',(function(e) {
        e.preventDefault();
        var formData = new FormData(this);
        jq.ajax({
            type:'POST',
            url: jq(this).attr('action'),
            data:formData,
            cache:false,
            contentType: false,
            processData: false,
            success: function(data)
        {
          jq(".no_image").css("display", "none"),
          jq(".show_image").css("display", "block"),
          jq(".profile_photo").val(function(index, currentValue) {
    return currentValue + data;
});
      jq(".image").attr("src","client_images/"+data);
        },
            error: function(data){
                console.log("error");
                console.log(data);
            }
        });
    }));
    jq(".inputFile").on("change", function() {
        jq(".upload").submit();
    });
$(function () {
    var options = {
        cell_height: 70
    };
    $('.grid-stack').gridstack(options);
     this.grid = $('.grid-stack').data('gridstack');
      this.save_grid = function () {
                    this.serialized_data = _.map($('.grid-stack > .grid-stack-item:visible'), function (el) {
                        el = $(el);
                        var node = el.data('_gridstack_node');
                        return {
                            x: node.x,
                            y: node.y,
                            width: node.width,
                            height: node.height
                        };
                    }, this);
                     $.ajax
    ({
        type: "POST",
        //the url where you want to sent the userName and password to
        url: 'save_grid.php',
        async: false,
        //json object to sent to the authentication url
        data: {'positions': JSON.stringify(this.serialized_data, null, '    ')},
        success: function () {
        alert("Positions Saved!"); 
        }
    })
                }.bind(this);

                $('#save-grid').click(this.save_grid);
                this.load_grid();
});

});
</script>

生活例子: http://troolee.github.io/gridstack.js/

尝试在初始化选项中设置float: true。除非你手动移动它,否则你的网格项不会向上或移动到任何地方。

例如:

$(function () {
    var options = {
        cell_height: 80,
        float : true
    };
    $('.grid-stack').gridstack(options);
});