Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User imoise's Avatar
    Join Date
    Sep 2007
    Location
    Bucharest,Romania
    Posts
    42
    Vote Rating
    0
    imoise is on a distinguished road

      0  

    Default Sencha touch store variable with @ prefix

    Sencha touch store variable with @ prefix


    Hi,

    I've stumbled over an interesting problem. I'm trying to develop an application that uses a cloud storage solution for my stores. I have a store configured with a proxy that retreives data from a remote URL. until now nothing fancy.
    The remote store cloud solution provides a image storing capability as well, so i upload the image on the server and in the store it reaches as a json object.

    stripping down other unimportant data this is the json structure,

    Code:
    {
    "image":"resources/images/hotel.jpg",
    "email":"mail@gmail.com",
    "server_image":{
    "@type":"Image",
    "@url":"http://files.storageroomapp.com/accounts/5199ded70f66022676001483/collection/5199e1a60f66027de90001c1/entries/5199ee9c0f66024dae00003e/fields/k519a1fc50f660201bd000ec5/file.jpg",
    "@processing":false,
    "@versions":{}
    
    }
    }
    If now in my template i have a
    Code:
    <IMG src="{server_image.@url}"
    this makes the XTemplate fail. With a uncaught SyntaxError : Unexpected token ) .

    If I map in the store with the mapping attribute in the model config, i get a UNEXPECTED TOKEN ILLEGAL error.

    I also tried using another field, with the "@" prefix and although it didn't give any error the image would not render and the page source did not contain anything . Upon removing the @ prefix the image rendered.

    any ideas of how i can solve this issue? I can't modify the api from the server so no matter how it will always give me that structure. and i need to use this online service.
    Do not underestimate the power under my imbecility...

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,067
    Vote Rating
    660
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User imoise's Avatar
    Join Date
    Sep 2007
    Location
    Bucharest,Romania
    Posts
    42
    Vote Rating
    0
    imoise is on a distinguished road

      0  

    Default


    Quote Originally Posted by evant View Post
    As I said mapping , just gives an error. Illeagal argument. As i found therebis a problem with the @ symbol. The proper way of reading feom a json in javascript for it is var x =myjson['@field'] . Not sure how to use this in a template though.
    Do not underestimate the power under my imbecility...

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,549
    Vote Rating
    873
    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


    You can do something like:

    Code:
    Ext.Viewport.add({
        tpl  : '{[values.server_image["@url"]]}',
        data : {
            server_image : {
                '@url' : 'foo'
            }
        }
    });
    Within the {[...]} you can execute plain javascript. You could also use the convert config to return the string in your model field.
    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.

Thread Participants: 2