This is a reduced version of my code but it still illustrates the issue I'm having. I'm trying to bind the puted property value with textValue.
Please note, that I know I can just do the basic as shown in this fiddle but this does not meet my needs.
In the large version of this code, not illustrated here, I perform modifications to value
before setting and modification to text
after getting. That's the gist of why I can't just use the default binding illustrated in the above fiddle.
JS
var App = Ember.Application.create();
App.ApplicationController = Ember.Controller.extend({
text: "Default",
textValue: function(key, value) {
if(arguments.length === 1) {
return this.get('text');
} else {
this.set('text', value);
}
}.property('text')
});
HTML
<script type="text/x-handlebars" data-template-name="application">
{{input value=textValue}}
<br>
TextValue: {{textValue}}
</script>
Fiddle
Thanks in advance!
This is a reduced version of my code but it still illustrates the issue I'm having. I'm trying to bind the puted property value with textValue.
Please note, that I know I can just do the basic as shown in this fiddle but this does not meet my needs.
In the large version of this code, not illustrated here, I perform modifications to value
before setting and modification to text
after getting. That's the gist of why I can't just use the default binding illustrated in the above fiddle.
JS
var App = Ember.Application.create();
App.ApplicationController = Ember.Controller.extend({
text: "Default",
textValue: function(key, value) {
if(arguments.length === 1) {
return this.get('text');
} else {
this.set('text', value);
}
}.property('text')
});
HTML
<script type="text/x-handlebars" data-template-name="application">
{{input value=textValue}}
<br>
TextValue: {{textValue}}
</script>
Fiddle
Thanks in advance!
Share Improve this question asked Mar 16, 2014 at 8:48 EasyCoEasyCo 2,03621 silver badges39 bronze badges2 Answers
Reset to default 5As of Ember.js 1.12, checking of arguments length is deprecated, since the discrete setter/getters for puted properties has been adopted.
textValue: Ember.puted('text', {
get() {
return this.get('text');
},
set(value) {
this.set('text', value);
}
})
It is required to return a value for your puted property
http://jsfiddle/EW7xD/2/
js
App.ApplicationController = Ember.Controller.extend({
text: "Default",
textValue: function(key, value) {
if(arguments.length === 1) {
return this.get('text');
} else {
this.set('text', value);
return this.get('text');
}
}.property('text')
});
or maybe simplify it
App.ApplicationController = Ember.Controller.extend({
text: "Default",
textValue: function(key, value) {
if(arguments.length > 1) {
this.set('text', value);
}
return this.get('text');
}.property('text')
});