Results 1 to 3 of 3

Thread: XTemplate / Conditions / Hyphens in Property-Names

  1. #1
    Sencha Premium User
    Join Date
    Apr 2007
    Location
    Vienna, Austria
    Posts
    59

    Default XTemplate / Conditions / Hyphens in Property-Names

    Hi!

    I would like to use a hyphenated property name in an XTemplate condition. I tried many variations of escape characters and special characters but nothing seems to work.

    Code:
    '<tpl if="start-date != end-date">',
       'blubb',
    '</tpl>',
    Is this possible at all? Any help is very much appreciated.

    Horst

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    The "-" character implies subtraction in Javascript. You can use them if you use subscript notation to acess the values, but if you are in control of the property names, then use valid ones like "startDate" and "endDate".

  3. #3
    Sencha Premium User
    Join Date
    Apr 2007
    Location
    Vienna, Austria
    Posts
    59

    Default

    Hi -

    thanks for your quick reply!

    Quote Originally Posted by Animal View Post
    The "-" character implies subtraction in Javascript. You can use them if you use subscript notation to acess the values, but if you are in control of the property names, then use valid ones like "startDate" and "endDate".
    I know that the hyphen has a special meaning. I just couldn't manage to use subscript notation in XTemplate conditions. I do want to use hyphens in my property-names in order to match them with the element-names in the XML-documents I am getting from the server.

    I think I found a solution - although a really ugly looking one:

    Code:
    '<tpl if="values[&quot;start-date&quot;].valueOf() != values[&quot;end-date&quot;].valueOf()">',
    Properties start-date and end-date are of type Date. I still don't understand why I have to use the method valueOf() though.

Posting Permissions

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