Custom Widget for Wakanda
The BindMe widget is an example of how to bind a datasource property to the widget
This widget has the following properties:
- value: The data binding value of the widget
The BindMe is an example of how to bind a datasource attribute to the widget using both the widget.js and designer.js
- Add the binding property and the onChange method in the widget.js
// the method addProperty automatically creates a bindable attribute
// it also adds that attribute to the Studio
BindMe.addProperty('MyName', {
onChange: function(v) {
this.node.innerHTML = "Hello " + v + ", how are you?";
}
});
////// IMPORTANT, NOTHING IS NEEDED IF YOU USED THE addAttribute method, but you can also manually do it by :
BindMe.addAttributes([{
name: 'data-value',
description: 'BindMe value',
typeValue: 'string',
defaultValue: ''
},{
name: 'data-binding-value',
description: 'BindMe with Source',
typeValue: 'datasource'
}]);
- Drag the widget to your Wakanda page.
- Select a datasource
- Drop a datasource string attribute to the widget
- Run the page, the string should be in the widget
- When the datasource changes its value in the page, the widget should respond accordingly
The BindMe CSS will define the background color of the widget.
You can adjust its color by changing directly in the Studio OR by changing the /css/widget.css file.
For more information on how to install a custom widget, refer to Installing a Custom Widget.
For more information about Custom Widgets, refer to Custom Widgets in the Architecture of Wakanda Applications manual.