Meteor.js - temporarily prevent a template from re-rendering (disable reactivity)

前端 未结 2 1128
太阳男子
太阳男子 2021-01-01 06:06

I have a page in my app with a list of Projects the user is working on.

When they want to add a new project, I show a modal form to get the name of the project.

2条回答
  •  死守一世寂寞
    2021-01-01 06:28

    You can put your html containing this into a {{#constant}} block. Docs on constant

    e.g

    {{#constant}}
        {{#each ...}}
        ....
        {{/each}}
    {{/constant}}
    

    Another option is to disable reactivity in your template helper e.g if you have

    Template.home.mydata = function() { return MyCollection.find() }
    

    change this to use reactive:false as an option

    Template.home.mydata = function() { return MyCollection.find({}, {reactive:false}) }
    

    This way the initial changes are shown but any updates aren't used so there wouldn't be a re-render.

提交回复
热议问题