PDA

View Full Version : Converting circular structure to JSON error



chaiwala
8 Mar 2012, 9:45 PM
I have a model such that one of its fields is another Ext.data.Store. For example, I have the following model, Meal, and its corresponding store, MealStore.

Ext.regModel('Meal', {
fields: [
{name: 'name', type: "string"},
{name: 'store', type: "auto"}, // this is the field for the store
],
proxy: {
type: 'localstorage',
id: 'meal-app-store'
}
});



Ext.regStore('MealStore', {
model: 'Meal',
sorters: [{
property: 'name',
direction: 'DESC'
}],
autoload: true,
proxy:{
type: 'localstorage',
id: 'meal-app-store'},
});



myApp.stores.mealStore = Ext.StoreMgr.get('MealStore');





I would like to add a data store with "Food" models to my "Meals."


store1= new Ext.data.Store({
model: 'Food',
autoload: true,
pageSize: 6,
proxy:{
type: 'sessionstorage',
id: 'modalFood-app-sessionstore'}

}),


When I attempt to do the following:



var finalMeal = Ext.ModelMgr.create({
name : "name",
store: store1,
}, 'Meal');

myApp.stores.mealStore.add(finalMeal);
finalMeal.save();


I get the following error:


Converting circular structure to JSON
The error occurs on the "finalMeal.save();" line.

I'm not sure why this is occurring. Can someone shed some light?

mitchellsimoens
9 Mar 2012, 7:36 AM
You should only save objects or arrays not full classes.