jQuery Resizing() UI 问题
一般来说,ressized() 工作得很好。这就是我遇到问题的地方。
- 我有一个 div,其中包含一些可以正常工作的可调整大小的项目(在某些时候对它们应用了 resizing() )。
- 用户可以保存项目以供以后查看(div 的 innerHTML 被保存到 JavaScript 数组中,然后 div 被清除,以便他们可以执行其他操作)
- 当项目被放回到 div 上时(从数组) - - 我执行 $('#divname').append(arrayname[i]); -- 项目不再可调整大小(尽管在视觉上它们具有可调整大小的类/句柄),
这就是到目前为止我已经尝试过(没有一个有效):
- 在append()行之后,我重新初始化了可调整大小的- $('#items').ressized();
- 在append()之后行,删除然后重新添加可调整大小 - $('#items').ressized('destroy').ressized();
感谢任何帮助 - 谢谢。
In general, resizable() works fine. Here is where I am getting into an issue.
- I have a div that contains some resizable items that work fine (resizable() applied to them at some point).
- user can save items for later view (the innerHTML of the div gets saved into a JavaScript array, then div gets cleared so they can do something else)
- When items get placed back onto div (from array) -- I do a $('#divname').append(arrayname[i]); -- items are no longer resizable (although visually they have the resizable classes/handle on them)
Here is what I have tried so far (none of which have worked):
- After append() line, I re-initialize the resizable -- $('#items').resizable();
- After append() line, remove then re-add resizable -- $('#items').resizable('destroy').resizable();
Any help is appreciated - thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的 - 我想出了如何解决这个问题。
在保存/存储 div 的 innerHTML 之前(如我的问题中的步骤 #2 中所述),我破坏了其中任何元素的“可调整大小”状态,如下所示( 示例选择器):
然后我将div的innerHTML存储到JavaScript数组中。
接下来,在重新填充 div 时,我附加了数组元素并重新初始化了可调整大小的项目,如下所示
:它们,但在存储innerHTML之前销毁可调整大小,然后在放回它们后重新初始化可调整大小(),一切正常。
所以这似乎已经解决了这个问题 - 希望它有所帮助。
Ok - I figured out what to do to solve this.
Before saving/storing the innerHTML of the div (as described in step #2 in my question), I destroyed the 'resizable' state of any elements in there like this (example selector):
Then I stored the innerHTML of the div into the JavaScript array.
Next, when repopulating the div, I appended the array element and re-initialized the resizable items like so:
So the issue seems to have been that storing the innerHTML which contained resizable() items did not work when re-appending/adding/rendering them, but destroying the resizables BEFORE storing the innerHTML, and then re-initializing resizable() once they were put back, it all works properly.
So this seems to have addressed the issue - hope it helps.