diff --git a/source/concepts/what-is-ember-js.md b/source/concepts/what-is-ember-js.md index ba1ce95ca..800b177bc 100644 --- a/source/concepts/what-is-ember-js.md +++ b/source/concepts/what-is-ember-js.md @@ -104,11 +104,11 @@ var president = Ember.Object.create({ firstName: "Barack", lastName: "Obama", - fullName: function() { + fullName: Ember.computed(function() { return this.get('firstName') + ' ' + this.get('lastName'); // Call this flag to mark the function as a property - }.property() + }) }); president.get('fullName'); @@ -124,15 +124,18 @@ You can tell Ember about these dependencies like this: ```javascript var president = Ember.Object.create({ - firstName: "Barack", - lastName: "Obama", + init: function() { + this._super.apply(this, arguments); + this.set('firstName', 'Barack'); + this.set('lastName', 'Obama'); + }, - fullName: function() { + fullName: Ember.computed('firstName', 'lastName', function() { return this.get('firstName') + ' ' + this.get('lastName'); - // Tell Ember that this computed property depends on firstName - // and lastName - }.property('firstName', 'lastName') + // Tell Ember that this computed property depends on firstName + // and lastName + }) }); ``` diff --git a/source/controllers/representing-a-single-model-with-objectcontroller.md b/source/controllers/representing-a-single-model-with-objectcontroller.md index 0e42ba83e..018a0ccfe 100644 --- a/source/controllers/representing-a-single-model-with-objectcontroller.md +++ b/source/controllers/representing-a-single-model-with-objectcontroller.md @@ -84,13 +84,13 @@ format for the template: ```app/controllers/song.js export default Ember.ObjectController.extend({ - duration: function() { - var duration = this.get('model.duration'), - minutes = Math.floor(duration / 60), - seconds = duration % 60; + duration: Ember.computed('model.duration', function() { + var duration = this.get('model.duration'); + var minutes = Math.floor(duration / 60); + var seconds = duration % 60; return [minutes, seconds].join(':'); - }.property('model.duration') + }) }); ``` diff --git a/source/controllers/representing-multiple-models-with-arraycontroller.md b/source/controllers/representing-multiple-models-with-arraycontroller.md index cf4397280..0579cafed 100644 --- a/source/controllers/representing-multiple-models-with-arraycontroller.md +++ b/source/controllers/representing-multiple-models-with-arraycontroller.md @@ -34,12 +34,12 @@ property called `longSongCount` to the controller: ```app/controllers/songs.js export default Ember.ArrayController.extend({ - longSongCount: function() { + longSongCount: Ember.computed('@each.duration', function() { var longSongs = this.filter(function(song) { return song.get('duration') > 30; }); return longSongs.get('length'); - }.property('@each.duration') + }) }); ``` @@ -75,11 +75,9 @@ creating an `ObjectController`: ```app/controllers/song.js export default Ember.ObjectController.extend({ - fullName: function() { - + fullName: Ember.computed('name', 'artist', function() { return this.get('name') + ' by ' + this.get('artist'); - - }.property('name', 'artist') + }) }); ``` diff --git a/source/cookbook/helpers_and_components/adding_google_analytics_tracking.md b/source/cookbook/helpers_and_components/adding_google_analytics_tracking.md index 5e489a6b4..3988697ee 100644 --- a/source/cookbook/helpers_and_components/adding_google_analytics_tracking.md +++ b/source/cookbook/helpers_and_components/adding_google_analytics_tracking.md @@ -40,12 +40,12 @@ var Router = Ember.Router.extend({ }); Router.reopen({ - notifyGoogleAnalytics: function() { + notifyGoogleAnalytics: Ember.on('didTransition', function() { return ga('send', 'pageview', { 'page': this.get('url'), 'title': this.get('url') }); - }.on('didTransition') + }) }); export default Router; diff --git a/source/cookbook/user_interface_and_interaction/adding_css_classes_to_your_components_based_on_properties.md b/source/cookbook/user_interface_and_interaction/adding_css_classes_to_your_components_based_on_properties.md index 5b0473d68..0b5a308d7 100644 --- a/source/cookbook/user_interface_and_interaction/adding_css_classes_to_your_components_based_on_properties.md +++ b/source/cookbook/user_interface_and_interaction/adding_css_classes_to_your_components_based_on_properties.md @@ -17,9 +17,9 @@ You can also set the class name based on a computed property. ```js classNameBindings: ['isActive'], -isActive: function() { +isActive: Ember.computed('someAttribute', function() { return 'active'; -}.property('someAttribute') +}) ``` Another way would be to bind the class name to a bound property. diff --git a/source/cookbook/user_interface_and_interaction/basic_form_validations.md b/source/cookbook/user_interface_and_interaction/basic_form_validations.md index fbb8e6038..0456826ed 100644 --- a/source/cookbook/user_interface_and_interaction/basic_form_validations.md +++ b/source/cookbook/user_interface_and_interaction/basic_form_validations.md @@ -16,11 +16,12 @@ been focused. The component expects to get the validation result as the export default Ember.Component.extend({ beenFocused: false, valid: null, - hasError: function() { + hasError: Ember.computed('valid', 'beenFocused', function() { if (this.get('beenFocused')) { return !this.get('valid'); } - }.property('valid', 'beenFocused'), + }), + focusOut: function() { this.set('beenFocused', true); } diff --git a/source/cookbook/user_interface_and_interaction/converting_strings_to_currency_with_accounting_js.md b/source/cookbook/user_interface_and_interaction/converting_strings_to_currency_with_accounting_js.md index 81bbd3a03..54d6940bc 100644 --- a/source/cookbook/user_interface_and_interaction/converting_strings_to_currency_with_accounting_js.md +++ b/source/cookbook/user_interface_and_interaction/converting_strings_to_currency_with_accounting_js.md @@ -10,15 +10,15 @@ Make use of the [computed property's setter][setters] to remove the display formatting and set the property to the proper value. ```js -formattedAmount: function(key, value) { +formattedAmount: Ember.computed('amount', function(key, value) { if (arguments.length > 1) { // setter var cleanAmount = accounting.unformat(value); this.set('amount', cleanAmount); } - + return accounting.formatMoney(this.get('amount')); -}.property('amount') +}); ```