I know that there is the .set() method to set a boolean to true or false but I want to know if there a method like .set() except it Toggles the value of a boolean.
In this case the boolean isEditing is being set to 'true'.
isEditing:false, actions: {   edit: function(category){     category.set('isEditing', true);     console.log(this.get('isEditing'))   }, } Here is the html
{{#if isEditing}}   <div class="category-text">      {{view Ember.TextField valueBinding=name action="turnOffEditMode"}}   </div> {{else}}   <div class="category-text">      {{#linkTo 'category' this}}       {{name}}     {{/linkTo}}   </div> {{/if}}   Method 1: Using the logical NOT operator: The logical NOT operator in Boolean algebra is used to negate an expression or value. Using this operator on a true value would return false and using it on a false value would return true. This property can be used to toggle a boolean value.
To toggle a boolean, use the strict inequality (! ==) operator to compare the boolean to true , e.g. bool !== true . The comparison will return false if the boolean value is equal to true and vice versa, effectively toggling the boolean.
this.toggleProperty('propertyName'); Edit: jsbin for proof
isEditing:false, actions: {     edit: function(category){         category.set('isEditing', !category.isEditing);         console.log(this.get('isEditing'))     }     toggleEditing : function(category){     } } Toggling the boolean value is what you need. Or yu can change your function like below.
isEditing:false, actions: {     toggleEditing : function(category){         category.set('isEditing', !category.isEditing);         console.log(this.get('isEditing'));     } } If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With