Gridstack – 单击调整堆栈项目大小

huangapple go评论86阅读模式
英文:

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...

huangapple
  • 本文由 发表于 2023年5月10日 12:56:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76215025.html
  • gridstack
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定