1. #1
    Touch Premium Member
    Join Date
    Nov 2011
    Posts
    8
    Vote Rating
    0
    ajchia is on a distinguished road

      0  

    Default Unanswered: XTemplate retriving a date from local storage in Safari doesn't work

    Unanswered: XTemplate retriving a date from local storage in Safari doesn't work


    But it does work in Chrome ST2.0 PR2 strangely enough.

    Ext.create('Ext.XTemplate', {startDateTime}) where startDateTime is of type date from a model,
    when rendered in a list shows a date in Chrome but when I open Safari on desktop or on iOS5 I get 'null' showing. It's strange because when inspecting localStorage I can see the date field ok.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Answers
    3541
    Vote Rating
    847
    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


    Are you defining your XTemplate exactly like:

    Code:
    Ext.create('Ext.XTemplate', {startDateTime})
    If so that is not valid, {startDateTime} is an invalid Object. Try something like this:

    Code:
    var tpl = Ext.create('Ext.XTemplate',
            '{startDateTime}',
            '<br>{title}'
    );
    
    var html = tpl.apply({
        startDateTime : new Date(),
        title         : 'Hi'
    });
    
    Ext.getBody().update(html);
    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
    Touch Premium Member
    Join Date
    Nov 2011
    Posts
    8
    Vote Rating
    0
    ajchia is on a distinguished road

      0  

    Default


    I didn't realize that thanks, I missed the quotes in the post sorry. I dug further and found that its nothing to do with the template. I tried just accessing the date from the record directly and it returns null in safari from local storage second time around but the store thinks its ok first time around ie it's shows immediately after a save and load (sync alone doesn't work as per other threads with localstore).

    However on page refresh the retrieved date comes out null. I fixed this by retyping the field to an int and using seconds from epoch. It's really odd.

  4. #4
    Touch Premium Member BostonMerlin's Avatar
    Join Date
    Aug 2010
    Location
    Boston
    Posts
    522
    Answers
    20
    Vote Rating
    41
    BostonMerlin has a spectacular aura about BostonMerlin has a spectacular aura about BostonMerlin has a spectacular aura about

      0  

    Default


    for what it's worth, I'm hitting the very same issue. saving a model to local storage and retrieving the first time around works fine in Chrome and Safari. Close the browser, start back up where data is read from local storage and that models date field values are listed as undefined in Safari but in Chrome they're correct. Using the latest sencha framework as of today. Still looking for a resolve.

    John
    I love being a dad (5 & 7), flying airplanes (KBED) and writing code (spaghetti).
    BostonMerlin aka John Bond aka JB
    See U @ SenchaCon '13