JavaScript EmberJS: toggleProperty set all properties of a Component to a default value

I'm trying to implement nested components in Ember 2.0.1, but I'm getting a strange behavior when use toggleProperty function inside of the action handler.

The first component looks like:

// ./components/comp-1.js
import Ember from 'ember';

export default Ember.Component.extend({
  prop1: false,
  hello: "Default text of comp-1",

  _changeHello: function() {
    this.set('hello', 'Text set by comp-1');
  }.on("init"),

  actions: {
    customAction1() {
      this.toggleProperty('prop1');
    }
  }
});

.

// ./templates/components/comp-1.hbs
<button {{action 'customAction1'}}>{{hello}}</button>

The second one is:

// ./components/comp-2.js
import Ember from 'ember';

export default Ember.Component.extend({
  data: [],

  _doSomeImportentStuff: function() {
    var data = this.get('data');

    data = [{name: 'Text set by comp-2', bool: false}, 
            {name: 'Text set by comp-2', bool: true}];

    this.set('data', data);
  }.on("init")
});

.

// ./templates/components/comp-2.hbs
{{#each data as |d|}}
{{comp-1 hello=d.name prop1=d.bool}}
{{/each}}

The component comp-2 creates two buttons with names Text set by comp-1. If I click on a button the text changes to Text set by comp-2 because of the execution of the function this.toggleProperty('prop1') that is called in the action handler customAction1. If I remove this function or remove the setting of prop1 from ./templates/components/comp-2.hbs then everything works as expected, i.e. text of the buttons stays always as Text set by comp-1.

Why does toggleProperty function set back other properties?

Am I doing something wrong?

The behavior in action can be seen here: http://ember-twiddle.com/90798b4952deb4a83de1

Answer:1

I'm having a problem where render is being called autimatically in my Marionette CompositeView which is correct, the problem is that I'm fetching collection data in the initialize and want this to be ...

I'm having a problem where render is being called autimatically in my Marionette CompositeView which is correct, the problem is that I'm fetching collection data in the initialize and want this to be ...

I am having an issue centring a <div id='divTwo'> inside another <div id='divOne'>. This is normal an easy thing to do, however in this instance i have transform: scale(); with transform-...

I am having an issue centring a <div id='divTwo'> inside another <div id='divOne'>. This is normal an easy thing to do, however in this instance i have transform: scale(); with transform-...

I am using Phonegap and jQuery to develop an app. I have a bit of a bug that has me stumped. I have a back button which looks like this: <div data-role="header"> <a id="...

I am using Phonegap and jQuery to develop an app. I have a bit of a bug that has me stumped. I have a back button which looks like this: <div data-role="header"> <a id="...

I am trying to implement a grid with grouping feature. This is my Model: Model Ext.define('myApp.model.ModelPrueba2', { extend: 'Ext.data.Model', fields: ['id', { name: 'name', type: 'string'...

I am trying to implement a grid with grouping feature. This is my Model: Model Ext.define('myApp.model.ModelPrueba2', { extend: 'Ext.data.Model', fields: ['id', { name: 'name', type: 'string'...

  1. extjs grid grouping multiple columns
  2. extjs grid grouping sort
  3. extjs grid grouping example
  4. extjs grid grouping
  5. extjs grid grouping expand all
  6. extjs grid grouping start collapsed
  7. extjs grid grouping not working
  8. extjs grid grouping collapse all
  9. extjs grid grouping checkbox
  10. extjs grid grouping collapse
  11. extjs grid grouping template
  12. extjs grid grouping tooltip
  13. extjs grid grouping feature
  14. extjs grid grouping column
  15. extjs grid group by multiple fields
  16. extjs grid group header
  17. extjs grid group order
  18. extjs grid group summary
  19. extjs grid group header checkbox
  20. extjs grid grouped column headers