Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception from Meteor.flush: TypeError: Cannot read property 'parentNode' of null

I've been running into a weird bug while working on Telescope. Currently, clicking submit on a post edit page triggers this error multiple time:

Exception from Meteor.flush: TypeError: Cannot read property 'parentNode' of null

I've narrowed it down to post_edit.html:

<div class="control-group post-form-category">
  <label class="control-label">Category</label>
  <div class="controls">
    {{#each categories}}
      <label class="radio inline">
        <input id="category_{{_id}}" type="radio" value="{{name}}" name="category" {{#if isChecked }} checked {{/if}}/> {{name}}
      </label>
    {{/each}}
  </div>
</div>

And here's the categories helper:

categories: function(){
  return Categories.find();
}

If you remove both {{#each}} loops (one in .post-form.category and another one in .post-form-user) the error goes away. Any idea what's going on? Am I doing something wrong with those {{#each}}?

UPDATE

It really seems like the problem is coming from the "checked" attribute. But even doing something like

<input type="radio" value="{{name}}" name="category" {{isChecked}} />

Still triggers the error.

like image 394
Sacha Avatar asked Nov 17 '25 14:11

Sacha


2 Answers

The problem is we don't support {{#if isChecked }} checked {{/if}}. You can't use a block helper (including #if) inside an HTML tag; you have to write a helper that returns the appropriate string instead.

like image 190
dgreensp Avatar answered Nov 19 '25 05:11

dgreensp


It turns out this is related to a bug in Meteor. Until the bug is fixed, there's a simple solution:

Make the #each in the SELECT not reactive, by going into post_edit.js and replacing Meteor.users.find() with Meteor.users.find().fetch().

Thanks to @dgreensp

like image 36
Sacha Avatar answered Nov 19 '25 05:11

Sacha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!