मुझे एम्बरजेस पर बाध्यकारी होने में परेशानी हो रही है। मैंने एक एम्बर टेक्स्टफील्ड को नियंत्रक के अंदर एक चर के लिए बाध्य किया है। जब मैं टेक्स्ट फ़ील्ड में लिखता हूं तो बाध्य चर सही ढंग से अपडेट हो जाता है।emberjs बाध्यकारी
अब मैं जेएस के माध्यम से चर (और टेक्स्ट फ़ील्ड में टेक्स्ट) को बदलना चाहता हूं। जब मैं करता हूं तो कुछ भी नहीं होता है।
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>
आह, धन्यवाद। मैंने पहले सेट करने की कोशिश की थी, लेकिन इसे गलत तरीके से इस्तेमाल किया था (और माना था कि यह गलत था)। – Nino