Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 清除旧流星订阅数据_Javascript_Meteor_Subscription - Fatal编程技术网

Javascript 清除旧流星订阅数据

Javascript 清除旧流星订阅数据,javascript,meteor,subscription,Javascript,Meteor,Subscription,我有一个Meteor模板,它使用动态订阅: var templateId = event.target.value; Meteor.subscribe('orderTemplateShow', templateId) templateId根据我选择的选择值而变化: <p><label>Select Template</label></p> <select id="templateSelect" name="t

我有一个Meteor模板,它使用动态订阅:

    var templateId = event.target.value;
    Meteor.subscribe('orderTemplateShow', templateId)
templateId根据我选择的选择值而变化:

    <p><label>Select Template</label></p>
    <select id="templateSelect" name="templateSelect">
        <option disabled selected> Select Template </option>
        {{#each orderTemplates}}
            <option value="{{this._id}}">{{this.templateName}}</option>
        {{/each}}
    </select>
一旦我选择了一个模板,模板的信息就会呈现在我在模板上的表上

我的桌子:

 <table id="templateItems" class="table">
            <thead>
                <tr>
                    <th>Product Code</th>
                    <th>Brand</th>
                    <th>Description</th>
                    <th>Member Price</th>
                    <th>Quantity</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                {{#each templateItems}}
                <tr>
                    <td>{{productCode}}</td>
                    <td>{{brand}}</td>
                    <td>{{description}}</td>
                    <td>${{memPrice}}</td>
                    <td><input type="text" id="qty" value ="{{quantity}}"></td>
                    <td><button class="btn btn-primary removeCartItem">Remove</button></td>
                </tr>
                {{/each}}
            </tbody>
        </table>
        </form>
但是,当我单击新模板时,除了我选择的新模板中的数据外,旧模板中的数据仍然显示在表中。因此,我有没有办法从旧订阅中动态删除数据


谢谢

订阅发布时,保留订阅句柄。然后,当您要取消订阅时,调用。停止以取消订阅

var subHandle = Meteor.subscribe('orderTemplateShow', templateId);
...
subHandle.stop()

弗洛伊德,这很有效。但是,我希望订阅停止从第二个下拉选择开始,并停止之后的每个选择。否则,每次选择新模板时,订阅都将停止。我会想办法的。非常感谢。查看一下需要自动运行和模板订阅的模板事件。看看我对你的回答。