Deprecated Views


#1

Upgrading from Ember 1.8 to 1.13.10. Have a view that does below

export default Ember.View.extend({
    willInsertElement : function () {
    this.get("controller").send ("show", true);
  },

  willDestroyElement : function () {
    this.get("controller").send ("show", false);
  },
});

How can I remove the view to fix the deprecation warnings?

I thought of creating a component and adding that to the corresponding template, but nothing happens. The component methods do not get called.

export default Ember.Component.extend({
  willInsertElement : function () {
    this.sendAction("show", true);
  },

  willDestroyElement : function () {
    this.sendAction("show", false);
  }
});

When adding to the template, do I have to pass specific actions? I tried calling it like this.

<activity-container><!--some html here--></activity-container>

Thanks in advance.


#2
{{#activity-container}}
<!-- markup you want to yield -->
{{/activity-container}}

Instantiating component via arrow syntax hasn’t landed yet.


#3

Thanks for your response. Its a progress, but still not working. It calls the willInsertElement, but then dies. and does not even call the willDestroyElement. In the debugger I see that if fails in this.sendAction(“show”, true); further going into that call, it finds actionName as undefined.

actionName = _emberMetalProperty_get.get(this, 'attrs.' + action) || _emberMetalProperty_get.get(this, action);
      actionName = validateAction(this, actionName);

      // If no action name for that action could be found, just abort.
      if (actionName === undefined) {
        return;
      }

I tried passing action=“show”, and that didn’t help either.

Also I had another developer use the arrow syntax and it is working, so not sure why mine is not.


#4

Actually, seems I found what was missing.

I updated the component as below and it called both methods. {{#activity-container class=“page” show=“show”}}

Thanks a bunch again for your help.


#5

Those angle bracket component syntax will be what you can use in the future though - so good guess.