• <bdo id='JnGoq'></bdo><ul id='JnGoq'></ul>
    1. <i id='JnGoq'><tr id='JnGoq'><dt id='JnGoq'><q id='JnGoq'><span id='JnGoq'><b id='JnGoq'><form id='JnGoq'><ins id='JnGoq'></ins><ul id='JnGoq'></ul><sub id='JnGoq'></sub></form><legend id='JnGoq'></legend><bdo id='JnGoq'><pre id='JnGoq'><center id='JnGoq'></center></pre></bdo></b><th id='JnGoq'></th></span></q></dt></tr></i><div id='JnGoq'><tfoot id='JnGoq'></tfoot><dl id='JnGoq'><fieldset id='JnGoq'></fieldset></dl></div>
      <legend id='JnGoq'><style id='JnGoq'><dir id='JnGoq'><q id='JnGoq'></q></dir></style></legend>
      1. <small id='JnGoq'></small><noframes id='JnGoq'>

        <tfoot id='JnGoq'></tfoot>

      2. 如何使用保存的 html 从 Gridstack 构建网格

        时间:2023-08-01

            <tfoot id='NRY5c'></tfoot>
            • <bdo id='NRY5c'></bdo><ul id='NRY5c'></ul>
                <tbody id='NRY5c'></tbody>
                • <small id='NRY5c'></small><noframes id='NRY5c'>

                  <legend id='NRY5c'><style id='NRY5c'><dir id='NRY5c'><q id='NRY5c'></q></dir></style></legend>
                  <i id='NRY5c'><tr id='NRY5c'><dt id='NRY5c'><q id='NRY5c'><span id='NRY5c'><b id='NRY5c'><form id='NRY5c'><ins id='NRY5c'></ins><ul id='NRY5c'></ul><sub id='NRY5c'></sub></form><legend id='NRY5c'></legend><bdo id='NRY5c'><pre id='NRY5c'><center id='NRY5c'></center></pre></bdo></b><th id='NRY5c'></th></span></q></dt></tr></i><div id='NRY5c'><tfoot id='NRY5c'></tfoot><dl id='NRY5c'><fieldset id='NRY5c'></fieldset></dl></div>
                  本文介绍了如何使用保存的 html 从 Gridstack 构建网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我一直在使用 Gridstack 来动态创建网格.我使用以下函数来序列化网格及其数据.但我似乎无法弄清楚如何从它创建的 JSON 数组构建我的网格它的内容.我检查了 https://github.com/troolee/gridstack.js#load-grid-from-array,但添加内容部分是整个问题.

                  I've been using Gridstack for dynamically creating a grid. I have used the following function to serialize the grid and it's data. But I can't seem to figure out how to build my grid and its content from the JSON array it created. Ive checked https://github.com/troolee/gridstack.js#load-grid-from-array, but adding the content part is the whole problem.

                  function saveData() {
                          var s_data = [];
                  
                          $('.grid-stack-item.ui-draggable').each(function () {
                              var $this = $(this);
                  
                              s_data.push({
                                  x: $this.attr('data-gs-x'),
                                  y: $this.attr('data-gs-y'),
                                  w: $this.attr('data-gs-width'),
                                  h: $this.attr('data-gs-height'),
                                  content: $('.grid-stack-item-content', $this).html()
                              });
                          });         
                      }
                  

                  这将创建以下数组:

                  [
                      {"x":"0","y":"0","w":"4","h":"2","content":"<h1>Test title for content</h1>"},
                      {"x":"4","y":"0","w":"4","h":"4","content":""}
                  ];
                  

                  所以我的问题是:如何使用这个数组构建我的网格,包括它的内容?

                  So my question is: how can I build my grid, including its content, using this array?

                  推荐答案

                  我回答了一个类似的问题 这里.

                  I answered a similar question here.

                  在你的情况下,你可以在gridstack序列化示例提供的load函数中使用如下代码:

                  In your case, you can use the following code in the load function provided by the gridstack serialization example:

                  this.load_grid = function () {              
                  
                      var items = GridStackUI.Utils.sort( this.s_data );
                      this.grid.remove_all();
                  
                      _.each( items, function( node ) {
                          this.grid.add_widget( jQuery( '<div class="grid-stack-item"><div class="grid-stack-item-content">' + node.content + '</div></div>' ), node.x, node.y, node.width, node.height );
                      }, this );
                  
                  }.bind( this );
                  

                  这篇关于如何使用保存的 html 从 Gridstack 构建网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:css font-size 和 line-height 与基线不匹配 下一篇:Bootstrap 响应式网格布局(3 列),每个网格元素下方具有折叠/隐藏的 col-12

                  相关文章

                    <small id='BVD5q'></small><noframes id='BVD5q'>

                    1. <tfoot id='BVD5q'></tfoot>
                    2. <i id='BVD5q'><tr id='BVD5q'><dt id='BVD5q'><q id='BVD5q'><span id='BVD5q'><b id='BVD5q'><form id='BVD5q'><ins id='BVD5q'></ins><ul id='BVD5q'></ul><sub id='BVD5q'></sub></form><legend id='BVD5q'></legend><bdo id='BVD5q'><pre id='BVD5q'><center id='BVD5q'></center></pre></bdo></b><th id='BVD5q'></th></span></q></dt></tr></i><div id='BVD5q'><tfoot id='BVD5q'></tfoot><dl id='BVD5q'><fieldset id='BVD5q'></fieldset></dl></div>

                      <legend id='BVD5q'><style id='BVD5q'><dir id='BVD5q'><q id='BVD5q'></q></dir></style></legend>
                        <bdo id='BVD5q'></bdo><ul id='BVD5q'></ul>