I have a scenario in emberjs component where the observe does not get hit. I figured out the reason as "the component is not yet inserted when the component property being observed is set."
My questions is, couldn this be handled in a better way in ember js?
Better explanation can be found in the below jsbin`s.
Not working Scenario
Working scenario
You can specify .on('init')
to force the observers to run right after initialization; otherwise like @Kingpin2k mentioned - they don't run
App.TextboxDisplayComponent = Ember.Component.extend({
displayText: '',
boundProperty: '',
observeBoundProperty: function () {
this.set('displayText', this.get('boundProperty'));
}.observes('boundProperty').on('init')
});
Your (non-)working example here
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