ember.js - How can I access an Ember input as a jQuery element? -


i have simple form in ember submits server , returns response. on failed response, want re-focus on input field. there way access field in controller using value binding?

here's jsbin example:

http://jsbin.com/umodir/1/edit

http://jsbin.com/efatut/2/edit

your server should return sets property on controller can observe. made pretty simple , called "error".

var app = ember.application.create();  app.applicationcontroller = ember.objectcontroller.extend({   error: false,   submit: function() {     alert('i want set focus on email input field now...');     this.set('error', true);   }   });  app.applicationview = ember.view.extend({   focusemail: function() {     if (this.get('controller.error')) {       this.$('input[type=text]').focus();     }   }.observes('controller.error') }); 

if wanted fancy use ember.component {{eb-input focuson="error"}} automatically focus when controller's "error" property changed.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -