Results 1 to 4 of 4

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

  1. #1
    Touch Premium Member
    Join Date
    Nov 2011
    Posts
    8
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Touch Premium Member
    Join Date
    Nov 2011
    Posts
    8
    Vote Rating
    0
      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
    548
    Answers
    22
    Vote Rating
    44
      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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •