Quantcast
Viewing all articles
Browse latest Browse all 4829

Render-modifiers

@Benjy1979 wrote:

When I try to use {{did-insert this.initialiseCategory}}, in my initialiseCategory function (which does get called) there is no “this”… it’s undefined. Any ideas?

 initialiseCategory() {
alert("test " + this); // 'this' is undefined
this.category.categoryIsOpen = true; // can't call category of undefined

}

<li {{did-insert this.initialiseCategory}}>
<a href="#" class="category-caption" {{on "click" this.toggleCategory}}><span>{{this.title}}</span>
     <span class="expand-icon">
      {{#if this.categoryIsOpen}}
        <img src="{{root-url}}/down.png"/>
      {{else}}
        <img src="{{root-url}}/up.png"/>
      {{/if}}
  </span>
</a>
category-item-component.js:71 Uncaught (in promise) TypeError: Cannot read property 'category' of undefined
at initialiseCategory (category-item-component.js:71)
at Object.installModifier (did-insert.js:62)
at index.js:7122
at untrack (validator.js:640)
at InteractiveCustomModifierManager.install (index.js:7122)
at TransactionImpl.commit (runtime.js:1667)
at EnvironmentImpl.commit (runtime.js:1803)
at inTransaction (runtime.js:1961)
at InteractiveRenderer._renderRoots (index.js:9043)
at InteractiveRenderer._renderRootsTransaction (index.js:9104)

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4829

Trending Articles