Akhenaten
29 Nov 2010, 2:47 PM
Hello all,
I have looked around the forums for this issue and didn't come across any pertinent posts, but feel free to direct me to a previous thread if I missed one.
I am attempting to take a List backed by a JSON store and save that data to local storage by instantiating another store. I found a post on Ed Spencer's blog talking about local storage in general and tried to apply it to my app, and although the code doesn't throw any errors, it doesn't send the data to local storage either. I am very new to not just Sencha Touch, but also to web application development, so please pardon my likely easily-solvable problem.
I have a model named "Patient" that contains various strings to describe a patient (name, rm_num, sex, dob, etc).
The List object's data is not loaded automatically, but rather on button press which loads the data from an Ajax proxy that receives JSON from a server-side PHP script. Here is the button code:
{
text: 'Load (Remote)',
ui: 'action',
centered: true,
handler: function() {
patList.getStore().load();
}
},
This button does work and loads the list appropriately when clicked. Once loaded, I want to "save" this data to local storage. Here is the code for the save button:
{
text: 'Save',
ui: 'action',
centered: true,
handler: function() {
var localStore = new Ext.data.Store({
proxy: new Ext.data.LocalStorageProxy({
id: 'patients'
}),
model: 'Patient'
});
localStore.sync();
}
},
When this "save" button is clicked, no error is thrown, but the data is not saved to local storage. Looking in Safari's web inspector, I see a "patients" key that is created (which I assume to come from the id I provided to the localStorageProxy), but there are no other keys or values. In my previous testing I saw how local storage writes additional keys with [id]-1 and then writes the data to the value for that key.
Please let me know if other code or debugging information is needed.
Thanks very much,
Ben Gohlke
I have looked around the forums for this issue and didn't come across any pertinent posts, but feel free to direct me to a previous thread if I missed one.
I am attempting to take a List backed by a JSON store and save that data to local storage by instantiating another store. I found a post on Ed Spencer's blog talking about local storage in general and tried to apply it to my app, and although the code doesn't throw any errors, it doesn't send the data to local storage either. I am very new to not just Sencha Touch, but also to web application development, so please pardon my likely easily-solvable problem.
I have a model named "Patient" that contains various strings to describe a patient (name, rm_num, sex, dob, etc).
The List object's data is not loaded automatically, but rather on button press which loads the data from an Ajax proxy that receives JSON from a server-side PHP script. Here is the button code:
{
text: 'Load (Remote)',
ui: 'action',
centered: true,
handler: function() {
patList.getStore().load();
}
},
This button does work and loads the list appropriately when clicked. Once loaded, I want to "save" this data to local storage. Here is the code for the save button:
{
text: 'Save',
ui: 'action',
centered: true,
handler: function() {
var localStore = new Ext.data.Store({
proxy: new Ext.data.LocalStorageProxy({
id: 'patients'
}),
model: 'Patient'
});
localStore.sync();
}
},
When this "save" button is clicked, no error is thrown, but the data is not saved to local storage. Looking in Safari's web inspector, I see a "patients" key that is created (which I assume to come from the id I provided to the localStorageProxy), but there are no other keys or values. In my previous testing I saw how local storage writes additional keys with [id]-1 and then writes the data to the value for that key.
Please let me know if other code or debugging information is needed.
Thanks very much,
Ben Gohlke