Ember.js Starter Kit
Based on latest version of Ember.js with the new router.
HTML
<script src="https://github.com/downloads/wycats/handlebars.js/handlebars-1.0.rc.1.js"></script>
<script src="https://gist.github.com/raw/4427466/a36a4f88a1a19f0b4ee38948af3bcdfa6c651d40/ember-latest.js"></script>
<script type="text/x-handlebars" data-template-name="index">
<h1>Fiddle for Stack Overflow</h1>
<a href="http://stackoverflow.com/questions/14234341/how-to-set-a-property-which-is-observable-but-not-run-observable-function-for-fe">
How to set a property which is observable but not run observable function for few cases in EmberJS
</a>
<hr/>
{{view MyApp.MyContainerView}}
</script>
<script type="text/x-handlebars" data-template-name="foo">
<pre>Click here to increment view.testProp: {{view.testProp}}</pre>
<pre>Observer has been called {{view.observerCount}} times</pre>
</script>
JavaScript
MyApp = Ember.Application.create({});
MyApp.Router = Ember.Router.extend();
MyApp.Router.map(function(match) {
match('/').to('index');
});
MyApp.MyContainerView = Em.ContainerView.extend({
childViews: ['foo'],
foo: Em.View.extend({
testProp: 100,
observerCount: 0,
click: function() {
console.log("click!", this.incrementProperty('testProp'));
},
testPropDidChange: function(){
console.log("Prop Observed by testPropDidChange! Value changed to: ", this.get('testProp'));
this.incrementProperty('observerCount')
},
init: function() {
this._super();
this.set('testProp', 200);//i want to avoid obeserver here
this.addObserver('testProp', this.testPropDidChange)
},
templateName: 'foo'
})
});