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

Updating other views' element attributes

In addition to class attributes, all other attributes of a view's element can be altered dynamically. For example, let's create a thumbnail view, as shown in the following code:

var thumb = Ember.View.create({
  tagName: 'img',
  attributeBindings: ['width', 'height', 'src'],
  width: 50,
  height: 50,
  src: 'http://www.google.com/doodles/new-years-day-2014'
});

This yields the following:

<img src='http://www.google.com/doodles/new-years-day-2014' width='50' height='50'>

The attributes' presence can be altered using bound Boolean properties. For example, we can disable a save button of a form if the corresponding input has not been filled, as shown in the following example:

// view App.FormButton = Em.View.extend({ tagName: ...

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