Gregg
Gregg

Reputation: 35864

EmberJS valueBinding without using Helpers

I know that by doing this

{{input id="name" valueBinding="name"}}

I can get the value of the name input in my controller like so:

App.CreateArmyController = Ember.ObjectController.extend({
  name: '',
  actions: {
    save: function() {
      alert(this.get('name'));
    }
  }
});

I'd prefer to be able to use standard HTML instead of the input helper. Is there a way to keep the HTML but still have the binding work? I also feel like this is a bit smelly to bind the values like this. If there is a better way to do this using Models, I'd be open to that idea.

Upvotes: 1

Views: 36

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

Short answer, no, this is definitely the best/correct way to do it in Ember for input fields.

Considering the binding, you don't have to use valueBinding, you could also do {{input value=name}}.

Upvotes: 1

Related Questions