我开始尝试使用GridStack来替换我用Gridster制作的页面。能够很好地使用bootstrap并做出响应的能力很有吸引力。
似乎缺少很大的文档,而我只是在努力保存数据。
这是我到目前为止拥有的页面- http://ededit.com/testing/test.html
我在堆栈溢出时发现了这个页面,当我移动或调整对象大小时,cod可以工作,但我不能通过单击按钮来访问数据
How can I parse gridstack.js items?
我的最终目标是单击一个"Save“按钮,让它输出json (id,width,height,x,y)
发布于 2015-01-25 02:48:37
我弄清楚了,我在github上发现了一个“问题”,并从那里弄清楚了。调用下面的函数将以json格式输出数据。
function saveData() {
var items = [];
$('.grid-stack-item.ui-draggable').each(function () {
var $this = $(this);
items.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()
});
});
alert(JSON.stringify(items));
}https://stackoverflow.com/questions/28128520
复制相似问题