How to replace content element in an Array Controller

Currently working on part of the app that requires cloning an element from the content, then modifying cloned element and saving back to model. I am having a problem when saving the cloned element and having to replace the old item with cloned one. What I am currently doing is changing all the properties of the old item like so (it works):

Blocks.replace = function(item1, item2) {
  for(var k in item2) {
    Ember.set(item1, k, item2[k]);

var selectedEmployment = this.get("controllers.employmentDataEntry").get("selectedEmployment");
var modelItem = content.findBy("@id", selectedEmployment["@id"]);
Blocks.replace(modelItem, selectedEmployment);

I'm trying to use the ArrayController replaceContent method, but I get an error saying "Invalid array length" when trying to run the following code:

var employmentIndex = content.indexOf(modelItem);
this.replaceContent(employmentIndex, 0, selectedEmployment);

Am I doing this incorrectly? Is there a better way of replacing an item? Note: I am using JSON as a model. The ArrayController that is used when calling replaceContent contains an array of length 2.


Fix: Need to send in an array to replaceContent method. So change selectedEmployment to [SelectedEmployment]. Also, change 0 to 1, otherwise, content will end up having both element and cloned element.

this.replaceContent(employmentIndex, 1, [selectedEmployment]);

Need Your Help

Multiple mysql_query?

php mysql sql

I'm making a simple script installation, in which the user enters the page, the system tables are created. The SQL code for these tables are in the same directory that I access via the file_get_con...