Note that there are some explanatory texts on larger screens.

plurals
  1. POAttempt to call loadedData when saving models in ember
    primarykey
    data
    text
    <p>I keep getting this error in my app but have no idea what is causing it. </p> <p>It happens whenever I commit my data store:</p> <p>Attempted to handle event <code>loadedData</code> on while in state rootState.loaded.updated.inFlight. Called with undefined</p> <p>Anyone?</p> <p>Here is the code that causes it:</p> <pre><code>var ts_setting; ts_setting = Cluey.Setting.find(Cluey.SettingsKeyIDs.API_TIMESTAMP); if (ts_setting.get('value') != null) { console.log("Found Timestamp"); } else { console.log("Creating Initial Timestamp..."); ts_setting.set("id", Cluey.SettingsKeyIDs.API_TIMESTAMP); ts_setting.set("value", 0); Cluey.store.commit(); } </code></pre> <p><strong>Edit</strong></p> <p>I have boiled it down to the following code (written in coffeescript) that is causing the error. The thing is, that the first time I run the code, when the object first does not exist in the data store, it runs fine. The error then happens when I run the code on a data store that already contains a record with the specified id. This might help you decipher what is happening. </p> <pre><code>ts_setting = Cluey.Setting.find(Cluey.SettingsKeyIDs.API_TIMESTAMP) ts_setting.get('value') ts_setting.set("id", Cluey.SettingsKeyIDs.API_TIMESTAMP) ts_setting.set("value", 0) Cluey.store.commit() </code></pre> <p><strong>Edit 2</strong></p> <p>I am having a similar problem creating a record:</p> <pre><code>ts_setting = Cluey.Setting.createRecord id: Cluey.SettingsKeyIDs.API_TIMESTAMP, value: 0 Cluey.store.commit() </code></pre> <p>The above code gives me this error: </p> <pre><code>Uncaught Error: Attempted to handle event `loadedData` on &lt;Cluey.Setting:ember327:1&gt; while in state rootState.loaded.created.inFlight. Called with undefined </code></pre> <p><strong>Edit 3</strong></p> <p>So it turns out I was calling <code>@timestamp = ts_setting.get('value')</code> just after committing the store which I suppose was causing the issue, as I was trying to fetch some data from an object that had not yet been saved.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload