【问题标题】:MeteorJS AccountTemplates Custom Field Stuck at Required ErrorMeteorJS AccountTemplates 自定义字段卡在必填错误
【发布时间】:2017-01-05 09:32:27
【问题描述】:

我在 Meteor 的用户帐户包中的 atSignUp 模板中遇到了这种奇怪的行为,我使用常规方式添加了一个自定义字段并将必填字段设置为 true,但是在 webapp 上,这个特定字段只会卡住显示错误消息“必填字段”,即使我更改了选择。我也在使用 useraccounts:semantic-ui,我到处寻找似乎找不到解决方案。

AccountsTemplates.addField({
  _id: "gender",
  type: "select",
  displayName: "Gender",
  required: true,
  select: [
    {
        text: "Male",
        value: "male",
    },
    {
        text: "Female",
        value: "female",
    }
  ]
}); //gender field

Screenshot of the occurrence

【问题讨论】:

    标签: javascript meteor meteor-accounts


    【解决方案1】:

    环顾四周后,我设法破解了一个解决方案。通过使用 Aldeed:meteor-template-extension 事件处理程序 Template.OnRendered() 并使用 jQuery 选择器在下拉菜单的隐藏输入字段的 id 上放置默认选择值。

    Template.onRendered(function () {
        //resolves the registration form gender selection issue
        const selectGender = $('#at-field-gender');
        if(selectGender.length){
            selectGender.val('male');
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-14
      • 1970-01-01
      • 2016-07-04
      • 1970-01-01
      • 1970-01-01
      • 2021-12-10
      • 2023-03-22
      • 2017-10-19
      相关资源
      最近更新 更多