1

任何人使用#with會遇到此問題?

//代碼在調用模板,助這裏只是用來傳遞參數的子模板

{{#with inputControlCheckboxHelper "middleName" "Middle Name" "" "middleNameDNA" "Address" "Alexander"}} 
{{> inputControlCheckbox}} 
{{/with}} 

//剛好路過的參數與這個輔助

Template.registerHelper("inputControlCheckboxHelper", 
function (inputName, inputTitle, inputSubTitle, checkboxName, templateName, inputPlaceHolder) { 
    return { 
     fieldName: inputName, 
     title: inputTitle, 
     subTitle: inputSubTitle, 
     checkbox: checkboxName, 
     template: templateName, 
     placeHolder: inputPlaceHolder 
    }; 
}); 

//子模板,這就叫另一個幫手

<template name="inputControlCheckbox"> 
{{#with shouldBeDisabled template checkbox}} 
    {{> afFieldInput name=../fieldName}} 
{{/with}} 

{{> afFieldInput name=checkbox type="boolean-checkbox"}} 
</template> 

//模板檢查上面的輸入是否應該是di sabled。

Template.registerHelper("shouldBeDisabled", function (formName, checkBoxName) { 
    var checkBox = AutoForm.getFieldValue(formName, checkBoxName); 

    if (checkBox === true) { 
     return {disableMe: true, notApplicable: "N/A"}; 
    } 
    else if (checkBox === false) { 
     return {disableMe: false, notApplicable: ""}; 
    } 
    else if (checkBox === "") { 
     return {disableMe: false, notApplicable: ""}; 
    } 
}); 

在Chrome控制檯,堆棧跟蹤看起來像這樣: enter image description here

如果我刪除{{#with shouldBeDisabled模板複選框}}行,我沒有得到任何例外。此外,即使有例外情況,所有內容都會顯示,並且複選框會與輸入一起使用。

我用鐵路由器1.0.1,流星1.0,並自動窗體4.0.1

回答

1

更新至4.0.2自動窗體解決的問題。

相關問題