Tengo problemas con el enlace de emberjs. He vinculado un campo de texto de color ámbar a una variable dentro de un controlador. Cuando escribo en el campo de texto, la variable enlazada se actualiza correctamente.emberjs binding
Ahora quiero cambiar la variable (y el texto en el campo de texto) a través de JS. Nada sucede cuando lo hago.
App = Ember.Application.create({});
App.FormInfo = Em.TextField.extend({
insertNewline: function(){
App.AController.clear();
}
});
App.AController = Em.ArrayController.create({
content: [],
name: '',
clear: function(){ //I want this function to clear the text field and set name to an empty string
this.name = '';
console.log(this.name);//expected empty string; actual user input
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://cloud.github.com/downloads/emberjs/ember.js/ember-0.9.5.min.js"></script>
<script type="text/x-handlebars">
{{view App.FormInfo placeholder="Name" valueBinding="App.AController.name"}}
</script>
Ah, gracias. Intenté establecer antes, pero lo usé incorrectamente (y asumí que era incorrecto). – Nino