Actions inside an EmberJS component

December 17, 2015 | Posted in EmberJS | Ajoy Oommen

I have been working on an application with a component that had an action which was not bubbling. After some digging, I found this:

… actions sent from inside a component are sent directly to the component’s Ember.Component instance, and do not bubble.

So, this component by itself will neither handle the action nor bubble it through the routers.

<script type="text/x-handlebars" id="components/post-summary">
  <h3 ></h3>
  
    <p>}</p>
  
</script>

Adding the following component will solve the issue.

App.PostSummaryComponent = Ember.Component.extend({
  actions: {
    toggleBody: function() {
      this.toggleProperty('isShowingBody');
    }
  }
});
EmberJS JavaScript

Related Posts

20 Feb 2016 » Streaming radio in a Cordova app

11 Oct 2015 » Content Security Policy for Cordova

26 Jul 2013 » A simple javascript game