在 Meteor 中添加对象后添加 JQuery UI Resizable

Adding JQuery UI Resizable after Adding Object in Meteor

当我将一个对象添加到我的 Meteor 应用程序中的 JQuery 个可调整大小的对象列表时,该对象在我刷新页面之前无法调整大小。

我应该添加什么样的事件侦听器或其他东西,在哪里?

我认为我的代码不是这个问题所必需的,但如果需要我一定会提出来的。

谢谢, --尼克

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();
});