- Basic Concepts
- Introduction
- Processing user interactions
- Nesting leaves
- Data Binding
- Tutorial
- Building a blog
- View Bridges
- Introduction
- The model
- Re-rendering
- Events
- Handling Children
- Controls
- Extending View Bridges
- Control Components
- What is a control?
- Text Controls
- TextBox
- TextArea
- PasswordTextBox
- Selection Controls
- The selection control pattern
- Standard Variants
- DropDown
- CheckSet
- RadioButtons
- SearchControl
- ModelSearchControl
- Attaching additional data
- Dynamically driving the available items
- File Uploads
- SimpleFileUpload
- Html5FileUpload
- Other
- Buttons
- Building your own control
- Application Components
- What is an application component?
- Pager
- Table
- SearchPanel
- Tabs
- Advanced Topics
- View Indexes
Children
Just as leaves and views are nested so too are their corresponding View Bridges. This allows compartmentalisation of the full UI into the Leaf/View/ViewBridge trilogy however most View Bridges need to interact with their host and/or children.
While the DOM is fully accessible to any Javascript and Javascript objects have no means to keep properties private, it is still considered poor practice for a parent View Bridge to 'reach inside' the DOM of a child View Bridge to manipulate it - DOM or View Bridge properties.
You should design your components with the following constraints:
- To communicate with your parent, raise a client side event.
- To communicate with a child use the 'findChildViewBridge' method to get a reference to the View Bridge class.
- Don't manipulate a child View Bridge directly. Create functions on the child View Bridge and call these from the parent.
findChildViewBridge
console.log(
this.findChildViewBridge('Email').getValue()
);
The argument to findChildViewBridge
is the name of the View Bridge and the response is the
View Bridge itself.
getSubLeaves
var viewBridges = this.getSubLeaves();
console.log(viewBridges[0].getValue());
This function returns an array of all child View Bridges.
getSubLeafValues
var viewBridgeValues = this.getSubLeafValues();
console.log(viewBridgeValues.Email);
Returns all the values of all child view bridges in an object. The value is evaluated by
calling getValue()
on each View Bridge in turn.
onSubLeafValueChanged
If you need to know when a child view bridge changes it's value you can override this function:
return {
onReady: function(){
},
onSubLeafValueChanged: function (viewBridge, newValue) {
console.log(viewBridge.leafName);
console.log(newValue);
}
};
This is often used to raise server events as the user changes values on a form.