Models.WallPost = Models.Value.extend({ classType: "MODELS.WALLPOST", date: null, targetobject: null, eventtype: null, changes: null, postInitialize: function() { //transform comments from an array to a collection of MODELS.WALLPOST if (!this.get("comment")) { this.set("comment", ""); } else { //this.set("comment", decodeURIComponent(this.get("comment")));Pe } if (this.get("comments")) { var commentsCollection = new Models.WallPostCollection(this.get("comments")); this.set("comments", commentsCollection); } else { this.set("comments", new Models.WallPostCollection()); } //parse old and new values if (this.get("changes")) { var newChanges = this.get("changes"); for (var j=0; j 0) { istherecomments = true; } if (this.get("comments")) { if (istherecomments) { comments = JSON.stringify(this.get("comments")); } } var comment = ""; if (this.get("comment")) { //comment = unescape(this.get("comment")); comment = this.get("comment"); } var nbchanges = 0; var istherechanges = false; if (this.get("changes")) { //comment = unescape(this.get("comment")); nbchanges = this.get("changes").length; if (nbchanges > 0) { istherechanges = true; } } if (this.get("targetobject")) { if (this.get("targetobject").object == "GroupActor") { isgroupactormessage = true; } if (this.get("targetobject").object.match(/^[a-z]*$|^[A-Z]*$/)) this.get("targetobject").object = this.get("targetobject").object.toLowerCase(); } var toReturn = { date: this.get("date"), targetobject: this.get("targetobject"), actor: this.get("actor"), isgroupactormessage: isgroupactormessage, eventtype: this.get("eventtype"), changes: this.get("changes"), iscreationevent: (this.get("eventtype")=="CREATION"), isfusionevent: (this.get("eventtype")=="FUSION"), isdeletable: this.get("isdeletable"), iscommentable: this.get("iscommentable"), amiowner: (this.get("actor").id==edContext().actorId), comments: comments, comment: comment, //comment: this.get("comment"), nbcomments: nbcomments, istherecomments: istherecomments, nbchanges: nbchanges, istherechanges: istherechanges }; //toReturn.targetobject.objectName = JSON.stringify(toReturn.targetobject.objectName); //console.log(toReturn.targetobject.objectName); //console.log(toReturn.targetobject.objectName.replace(new RegExp('"', 'g'), '\"')); return toReturn; } }); Models.WallPostCollection = Models.BaseCollection.extend({ classType: "MODELS.WALLPOSTCOLLECTION", model: Models.WallPost, getAdditionalJSONObject: function() { var toReturn = { iscommentable: this.iscommentable }; return toReturn; } });