Search code examples
meteoriron-routermeteor-blazemeteor-helpermeteor-autoform

Exception in template helper: Error: Can't use $ on template instance with no DOM


Anyone run into this issue using a #with?

// Code in the calling template, Helper here just used to pass parameters a sub template

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

// Just passing in parameters with this helper

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

// The sub template, this calls another helper

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

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

// The template to check if the input above should be disabled.

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: ""};
    }
});

In the Chrome console, the stack trace looks like so: enter image description here

If I remove the {{#with shouldBeDisabled template checkbox}} line, I get no exception. Also, even with the exception, everything renders find and the checkbox works with the input.

I'm using Iron Router 1.0.1, Meteor 1.0, and Autoform 4.0.1


Solution

  • Update to Autoform 4.0.2 solved the issue.