简体   繁体   English

当Accounts.createUser引发错误时,流星模板重新渲染

[英]Meteor Template re-renders when Accounts.createUser throws error

So basically I have a template and within that template I have a template that renders a form. 所以基本上我有一个模板,并且在该模板中,我有一个呈现表单的模板。 Attached to the form is a submit event that when triggered, validates the from data and calls Accounts.createUser. 附加到表单的是一个提交事件,该事件被触发时,将验证from数据并调用Accounts.createUser。

In the case that Accounts.createUser throws an error it, for some unknown reason, causes the upper level template to re-render in turn the second level template re-renders thus removing the values in the form fields and discarding the errors that were inserted below each field using jquery. 在Accounts.createUser引发错误的情况下,由于某种未知原因,它将导致重新渲染上层模板,然后重新渲染第二层模板,从而删除表单字段中的值并丢弃所插入的错误在每个字段下方使用jquery。

If Accounts.createUser doesn't throw an error, everything works fine, user is "logged in" and the inner page is rendered properly.. 如果Accounts.createUser没有引发错误,则一切正常,“登录”用户,并且内部页面正确呈现。

Is this a bug in Meteor? 这是流星中的错误吗? I don't see why Accounts.createUser throwing an error would cause a template re-render.. 我看不到为什么Accounts.createUser抛出错误会导致模板重新呈现。

1) Check all dependencies for the upper template. 1)检查上模板的所有依赖项。 Does any of its data depend on createUser result? 是否有任何数据取决于createUser结果? Double-check all Session variables. 仔细检查所有Session变量。

2) Do you have a callback in the createUser call? 2)您在createUser调用中是否有回调?

3) Try putting your form template within a {{#constant}} block. 3)尝试将表单模板放在{{#constant}}块中。 This should prevent rerendering and losing data. 这样可以防止重新呈现和丢失数据。 Also, if you use preserveInputs package, remember that input data is preserved only for inputs that have either id or name set. 另外,如果你使用preserveInputs包,请记住,输入数据将被保留为要么输入idname集。

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

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