1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    3
    Vote Rating
    0
    zeth.bw is on a distinguished road

      0  

    Default Unanswered: localstorage usage sync

    Unanswered: localstorage usage sync


    Hi,

    just a dummy question from a new user.

    i try to save data to the localstorage and i must miss something

    the example http://docs.sencha.com/touch/2-0/#!/...re-method-sync failed

    and here is my interpretation:

    Code:
            Ext.define('MyApp.model.Search', {
                extend: 'Ext.data.Model',
                config: {
                    fields: [
                        { name: "id" },
                        { name: "query", type: "string" }
                    ],
    
    
                    proxy: {
                        type: 'localstorage',
                        id  : 'twitter-Searches'
                    }
                }
            });
    
    
            var store = Ext.create('Ext.data.Store', {
                model: 'MyApp.model.Search'
            });
    
    
            var search = new MyApp.model.Search({query: "Sencha Touch"});
    
    
            store.add(search);
    
    
            store.sync();


    it seems to be a model object format error.

    Any help please.

    Thanks

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,224
    Answers
    3522
    Vote Rating
    859
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    That code worked for me. What ST2 version are you trying this on?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    3
    Vote Rating
    0
    zeth.bw is on a distinguished road

      0  

    Default


    thank for the answer

    my probleme seem to be more complicated.

    when i do this way there is no probleme

    Code:
    Ext.application({    name: 'Axones',
    
    
        icon: 'resources/img/icon.png',
        tabletStartupScreen: 'resources/img/tablet_startup.png',
        phoneStartupScreen: 'resources/img/phone_startup.png',
    
    
        models: [
            'User'
        ],
    
    
        profiles: [
            'Tablet', 'Phone'
        ],
    
    
        launch: function(){
            var store = Ext.create('Ext.data.Store', {
                model: 'Axones.model.User'
            });
    
    
            var User = Ext.ModelManager.getModel('Axones.model.User');
    
    
            var o = new User({name: "Sencha Touch"});
    
    
            store2.add(o);
    
    
            store2.sync();
        }
    });
    but there is an error with the store declaration

    Code:
    Ext.application({    name: 'Axones',
    
    
        icon: 'resources/img/icon.png',
        tabletStartupScreen: 'resources/img/tablet_startup.png',
        phoneStartupScreen: 'resources/img/phone_startup.png',
    
    
        stores: [
            'Users'
        ],
    
    
        models: [
            'User'
        ],
    
    
        profiles: [
            'Tablet', 'Phone'
        ],
    
    
        launch: function(){
            var store = Ext.getStore('Users');
    
    
            var User = Ext.ModelManager.getModel('Axones.model.User');
    
    
            var o = new User({name: "Sencha Touch"});
    
    
            store2.add(o);
    
    
            store2.sync();
        }
    });
    and in User.js in folder 'store'

    Code:
    Ext.define('Axones.store.Users', {    extend: 'Ext.data.Store',
        requires: 'Axones.model.User',
        model: 'Axones.model.User'
    });

Thread Participants: 1