rmitchell62@me.com
27 Jan 2011, 7:57 AM
I'm trying to make the following, which seems like it would be pretty comment.
a select 'dropdown' (eg. select one of 'apple' 'orange' 'pear') and
a templated panel that lists attributes of the selected fruit.
So, I want to be able to only show the attributes for 'apple', when 'apple' is selected from the dropdown.
A template fills in the dropdown just fine. A second template can display the attributes data for all fruits. I am trying to limit this to the selected fruit.
eg. <tpl for="fruit">
<tpl if="name= "apple"">
<div>This fruit is {colour}</div>
</tpl></tpl>
works fine. However I don't want to compare to a static string I need to fetch the value from the select. I've
tried many combinations. For instance I create a variable outside of the template
var this.selectedFruit = "apple";
and inside the template:
<tpl if="name== this.selectedFruit">
but no go. I've tried every permutation of escaping and quoting I can think of. Is there any way to read a variable (that isn't part of the template data) from within the template? How might I read a global var, or call a javascript function or query a ui element value? ( I've tried [{...}] to no avail - is this supposed to work from inside an 'if='?
Please, please, please improve the documentation and provide more thorough examples for XTemplate because it is very powerful. Flailing around trying to guess the syntax is a slow and frustrating process.
a select 'dropdown' (eg. select one of 'apple' 'orange' 'pear') and
a templated panel that lists attributes of the selected fruit.
So, I want to be able to only show the attributes for 'apple', when 'apple' is selected from the dropdown.
A template fills in the dropdown just fine. A second template can display the attributes data for all fruits. I am trying to limit this to the selected fruit.
eg. <tpl for="fruit">
<tpl if="name= "apple"">
<div>This fruit is {colour}</div>
</tpl></tpl>
works fine. However I don't want to compare to a static string I need to fetch the value from the select. I've
tried many combinations. For instance I create a variable outside of the template
var this.selectedFruit = "apple";
and inside the template:
<tpl if="name== this.selectedFruit">
but no go. I've tried every permutation of escaping and quoting I can think of. Is there any way to read a variable (that isn't part of the template data) from within the template? How might I read a global var, or call a javascript function or query a ui element value? ( I've tried [{...}] to no avail - is this supposed to work from inside an 'if='?
Please, please, please improve the documentation and provide more thorough examples for XTemplate because it is very powerful. Flailing around trying to guess the syntax is a slow and frustrating process.