MeteorJS:显示/隐藏留下空白div

时间:2015-08-12 07:57:30

标签: javascript meteor meteor-autoform

我正在根据companyName回答

更改customerType的字段类型来显示/隐藏

enter image description here enter image description here

它可以工作,但不是隐藏整个div,它似乎只是使不透明度为0,留下像这样的空白

enter image description here

当我检查元素时,它显示的形式是没有内容的组div

enter image description here

更新:我正在尝试将依赖逻辑保留在架构上。这样我就可以拥有1个表单html模板,并让每个表单的模式处理它的显示/隐藏逻辑。这种方法可以很容易地维护表单。我试图避免每个字段发出{{#if variable}} {{/ if}}。

如果字段被隐藏,有没有办法删除空白div?

2 个答案:

答案 0 :(得分:1)

您可以将类型架构更新为" none"并在你的观点:

<div class="form-group" style="display: {{type}}">
  Put your custype div/input fiel here
</div>

免责声明:未经测试。

答案 1 :(得分:0)

您可以创建新助手:

isCompany: function(){
    return Autoform.getFieldValue("customerType") == "Company"; 
   // return true if custype is company
}

在您的客户div块上:

{{#if isCompany}}
   Put your custype div/input fiel here
{{/if}}

---这样,当公司成为公司时,公司的div块将被显示出来。

对不起,如果有拼写错误的话。我在移动设备上。

相关问题