O'Reilly logo

Mastering Ember.js by Mitchel Kelonye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using built-in views (components)

In Chapter 4, Writing Application Templates, we promised to discuss the built-in views that Ember.js provides. Most of these are high-level views (components) from controls that guarantee painless design of forms.

Textfields

The textfield view is used to create a bound text input in a form. It's usually created from the Ember.TextField class. We can subscribe to the input's value changes by implementing the view's change event handler, as shown in the following code:

App.InputView = Ember.TextField.extend({
  change: function(event){
    console.log(this.get('value')); 
  }
});

Just like any other view, we can insert this view into a template as:

{{view App.InputView name='name' valueBinding='controller.name'}}

In this example, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required