简体   繁体   English

在流星中添加对象后添加可调整大小的JQuery UI

[英]Adding JQuery UI Resizable after Adding Object in Meteor

When I add an object to a list of JQuery Resizable objects in my Meteor app, the object is not re-sizable until I refresh the page. 当我在Meteor应用程序中将对象添加到JQuery Resizable对象列表中时,在刷新页面之前,该对象不会重新调整大小。

What kind of event listener or something should I add, and where? 我应该添加哪种类型的事件侦听器,或者在哪里添加?

I figured my code wasn't necessary for this question, but I will definitely put it up if requested. 我认为我的代码对于这个问题不是必需的,但是如果有要求,我一定会提出。

Thanks, --Nick 谢谢-尼克

EDIT: A note for future readers of this question (if any), I decided to go with ryanswapp:interactjs. 编辑:对于这个问题的未来读者的说明(如果有的话),我决定使用ryanswapp:interactjs。 Worked right out of the box. 开箱即用。 The less JQuery the better (in my opinion). JQuery越少越好(我认为)。

The most reliable way to init UI elements in a list is by creating a template for each item, then use the onRendered event of the template to execute the function. 初始化列表中UI元素的最可靠方法是为每个项目创建一个模板,然后使用模板的onRendered事件执行该功能。

list.html list.html

...
<ul>
    {{#each items}}
        {{> ItemTemplate}}
    {{/each}}
</ul>
...

item-template.html 项目-template.html

<template name="ItemTemplate">
    <li>
        <div class="resizable">
            {{content}}
        </div>
    </li>
</template>

item-template.js 项目-template.js

Template.ItemTemplate.onRendered(function() {
    this.find('.resizable').resizable();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM