0

Interesting, i don't know how to update object in an array.

see this jsFiddle

i am getting this error.

Uncaught TypeError: Object #<Object> has no method 'set' 

i tried in many ways.

target.id = "Degree";
Ember.set('target.id', 'degree');

nothing helps.

Code i tried.

App.Config = [{id: "Gender"}, {id: "Martial Status"}];

var target = App.Config.findProperty("id", "Gender");

target.set("id", "Degree"); //see error in console.

1 Answer 1

1

Your App.Config is just an array of plain javascript objects, not Ember objects, so it doesn't know what set is. To fix, we need to create an array of Ember objects:

App = Ember.Application.create({});

App.Config = [
  Ember.Object.create({id: "Gender"}), 
  Ember.Object.create({id: "Martial Status"})
];

var target = App.Config.findProperty("id", "Gender");
console.log(target.get('id'));
target.set("id", "Degree"); //see updated values in console.
console.log(target.get('id'));

Working example http://jsbin.com/aqaber/1/edit

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.