Recent Changes - Search:





Element properties and model variables

To connect a model variable with a view element property, simply type the model variable name into the corresponding property field in the properties editor of the element. This simple input makes the connection.


This connection is bidirectional, which means that whenever the model variable changes, the view element automatically receives the new value and changes consequently. And viceversa, when the user interacts with the view element in a way that this property is affected, the new value is passed back to the model variable. Simple, and effective.


Instead of typing the model variable, you can also choose the variable that will be linked to the property using the second icon to the right of the property field. This icon looks link a chain link and will display a dialog with a list of all model variables that can be linked to this property. (Only variables of the right types will be listed.) Double-click the one you want and EJS will input it in the property field.


Sometimes, you will see that EJS writes this variable surrounded with percent characters, as in %aVariable%. Although this is valid, and tells EJS explicitely that aVariable is a model variable, this is only needed when the property is of type String (and then also the variable) to resolve the ambiguity created if you would type simply aVariable. Would that mean the literal “aVariable” or the variable called aVariable?


To help write clearer code, we always recommend to write String literals using quotes, as in “aVariable”, but because many people forget to do so, EJS is very forgiving and assumes the literal. (It also adds the quotes automatically for you .)

Edit - History - Print - Recent Changes - Search
Page last modified on February 09, 2010, at 12:04 AM