I'm doing an ajax form with a server API calls. The server can returns errors messages for specific fields (example: url => 'This url is incorrect').
So I've created a specific view for my form Textfield :
(textfield.handlebars)
{{view Ember.TextField valueBinding="value"}}
{{#if hasError}}
<div class="error">{{errorMessage}}</div>
{{/if}}
(textfield.js)
App.TextField = Ember.View.extend({
hasError: false,
errorMessage: "",
templateName: "textfield",
});
And In my form view template I have:
(form.handlebars)
<div class="form-row">
<div class="form-element"><div class="input-wrapper">{{view App.TextField valueBinding="skill.job"}}</div></div>
</div>
(new.js)
submit: function() {
var skill = this.get("skill");
skill.saveResource()
.fail( function(e) {
//how could I set the errorMessage in my App.TextField
});
}
When the user click on the submit button, I'm sending all form datas to the server and retrieving errors messages.
My question is how can I do to update the "subview" App.TextField to set the error messages ?