当我将一个对象添加到我的 Meteor 应用程序中的 JQuery Resizable 对象列表时,该对象在我刷新页面之前无法调整大小。
我应该添加什么样的事件监听器或其他东西,在哪里添加?
我认为我的代码不是这个问题所必需的,但如果需要,我一定会提出来。
谢谢, --尼克
EDIT: A note for future readers of this question (if any), I decided to go with ryanswapp:interactjs. Worked right out of the box. The less JQuery the better (in my opinion).
最佳答案
在列表中初始化 UI 元素的最可靠方法是为每个项目创建一个模板,然后使用模板的 onRendered
事件来执行函数。
list.html
...
<ul>
{{#each items}}
{{> ItemTemplate}}
{{/each}}
</ul>
...
item-template.html
<template name="ItemTemplate">
<li>
<div class="resizable">
{{content}}
</div>
</li>
</template>
item-template.js
Template.ItemTemplate.onRendered(function() {
this.find('.resizable').resizable();
});
关于javascript - 在 Meteor 中添加对象后添加可调整大小的 JQuery UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36926194/