Accessing on-screen controls from script |
Top Previous Next |
All on-screen controls that you place on pages can be accessed programmatically from script. This allows you to retrieve values, for example, from a slider, or set properties. This is done by typing in "control." followed by the ID of the control. This is a function, so you'll pass in values to the function to retrieve, make changes, and call any member functions of the control. For example, if you have a variable value control with an ID of "myVal", you'd put: control.myVal("option","caption","new caption") to change the caption to "new caption". All properties are accessed by passing "option" as the first parameter, and the property name as the second parameter. If a third parameter is specified, then the property is changed to that value. If not, then the property is retrieved instead, so: control.myVal("option","caption") would return "new caption". Please refer to the sections on the controls to see what properties are available and what their names are. Remember, Javascript is case sensitive! Advanced: all controls are actually jQuery UI objects and thus follow the same pattern, with some exceptions. control.controlID() is almost the same as $("#controlID").controlType() except that we allow you to change just parts of properties that are objects without having to set the entire object. The same goes for arrays. You can access controls through $() notation, however you'd have to know our the full UI type for the control and our additions won't apply and you'll have to fully specify objects and arrays. If you are going to access properties from outside, we recommend going through the sandbox: $.dc.sandbox.control.controlID() unless you are just going to use standard jQuery functions on it. That said, if you want to use normal jQuery functions like css() to do things like move the control, you will have to use the jQuery $() notation as described in the next section. |