简体   繁体   English

检测余烬文本区域的变化

[英]detect changes in ember textarea

I've been developing a new interface where I have a ember textarea: 我一直在开发一个具有余烬文本区域的新界面:

{{textarea value=name cols="80" rows="6"}}

But I was wondering how can I detect when the user makes changes (using an action for example) in order to alert him to save or not his work? 但是我想知道如何检测用户何时进行更改(例如使用操作)以提醒他保存或不保存他的工作?

Thanks 谢谢

In your specific case: 在您的特定情况下:

// in your controller

nameObserver: function () {
    var name = this.get('name');
    // maybe compare with old name value
    this.set('isDirty', true); // use this property in your handelbars to show a 'Don't forget to save!' message
}.observes('name')

bind to a observed value that is bind to the value of the text area in your controller 绑定到观测值,该观测值绑定到控制器中文本区域的值

for example: 例如:

txVal: '',
obsTxtVal: function(){
  console.log('Changed', this.get('txVal'));
}.observes('txVal'),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM