Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save runspired/90e24e607ea7030ad5dd to your computer and use it in GitHub Desktop.
Save runspired/90e24e607ea7030ad5dd to your computer and use it in GitHub Desktop.
Changing Attribute Bug
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
time: new Date(),
showYield: false,
actions: {
updateTime() {
this.set('time', new Date());
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#if showYield}}
<h2>Out showYield is True</h2>
{{/if}}
<hr>
{{#outer-component time=time showYield=showYield}}
<p>This is yielded</p>
{{/outer-component}}
<hr>
<br>
<button {{action 'updateTime'}}>Update Time</button>
<br><br>
Repro Step:
<ol>
<li>Click Show Yield to set showYield to true</li>
<li>Click Update time which updates another attribute on the component</li>
<li>Notice that showYield is reset back to false</li>
</ol>
import Ember from 'ember';
export default Ember.Component.extend({
showYield: false,
_showYield: Ember.computed.oneWay('showYield'),
actions: {
showYield() {
this.set('_showYield', true);
}
}
});
Time: {{time}}
{{#if _showYield}}
{{yield}}
{{else}}
<p>You are not showing yield</p>
{{/if}}
<button {{action 'showYield'}}>Show Yield</button>
{
"version": "0.5.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment