Dynamically add js object to model array in 1.13


#1

I have the following code:

var msg = this.store.createRecord({text:‘first title’, createdAt: “2015-06-22T20:06:06+03:00” })

this.get(‘model.content’).pushObject(msg);

msg.save();

We create new record. Then push in it to the model to display. It worked perfectly in 1.9 version but after upgrading it to the newest 1.13 it breaks and show this error

TypeError: internalModel.getRecord is not a function

after some researches I came out to this solution

_this.get(‘messages.content’).unshiftObject(message._internalModel);

and it partially help. Now I have two problems:

  1. I’m not confident if using private ember data api is a good idea
  2. I have an annoying delay between adding record to the model and rendering it on the screen. More than that if I don’t call msg.save(); the record isn’t rendered. So as far as I understood it waits until we have response from server and only then renders it. But I need opposite behaviour - I need to show the record first and then save it(showing the saving state for the user), this way user thinks that everything goes extrimely fast.

#2

Is content a hasMany attribute in your model? Otherwise this doesn’t make much sense. Could you post your model definition? It might shed some light into your issue.