英文:
Gridstack - Resize stack item by click
问题
我正在使用Gridstack。到目前为止,一切都运行正常。现在我正在尝试找到一个解决方案,通过点击来更改项目的大小。
我通过JavaScript在点击事件中更改了项目属性"gs-w"和"gs-h"。这会暂时更改大小,但在下次拖放操作时,旧的大小会再次出现。而且它也不会重新排列其他项目的位置。
有人能给我一个提示,如何正确做这个吗?
英文:
I'm using Gridstack. So far everything works fine. Now I'm trying to find a solution to change the size of an item by a click.
I changed the item attributes "gs-w" and "gs-h" by JS on click. This changed the size temporary, but on the next drag&drop the old sizes comes again. And it's also not rearranging the position of the other items around.
Could somebody give me a hint, how to do it correctly?
答案1
得分: 1
经过长时间的尝试,我找到了解决办法:
在 Update 方法中必须是你想要更改的项目的类(而不是 id!)。"opt" 必须是一个包含 x、y、w 和 h 的数组。
最终用 jQuery 看起来像这样:
('#button').click(function(){
GridStack.update('the-class', {x:10,y:10,w:2,h:4});
});
正如我所期望的那样简单。但是你怎么知道它必须是类和数组...
英文:
After long trying I found the solution:
In the Update method has to be the class of the item, which you want to change (not the id!). And the "opt" has to be an array with x,y,w,h.
Finally with jQuery it looks like:
('#button').click(function(){
GridStack.update('the-class', {x:10,y:10,w:2,h:4});
});
It is as simple as I expected. But how can you know, that it has to be the class and an array...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论