API Status: Development
- Description:
API Status: Development
- Source:
Methods
addListeners(widget)
- Description:
When the Binding is bound to a Widget, it can start listening for events
from that Widget. Override this method as needed.You may find it helpful to call
addWidgetEventsfrom your override of this
method.
- Source:
- See:
-
- module:nmodule/bajaui/rc/binding/impl/widgetEvents
Parameters:
| Name | Type | Description |
|---|---|---|
widget |
module:bajaux/Widget |
addWidgetEvents(widget, events)
- Description:
Registers the provided events on the widget and keeps track of these
events which are disarmed with the default implementation of
Binding#removeListeners.The added listeners will fire in the order they were added to the widget.
The handler for a listener may optionally return false which will cause
the later event handlers to no longer fire. The provided handler for an
event also executes in order, asynchronously via promises. This means
it will wait for the async operation to finish prior to moving on to the
next event of the same type. Valid event types include both JQuery and
bajaux events.Note that this is a convenience method and overriding this will not gain
your Binding subclass any functionality.
- Source:
Examples
binding.addWidgetEvents(widget, {
click: () => {
// do something when click happens
}
});
binding.addWidgetEvents(widget, {
click: () => {
// This promise will resolve prior to executing the second click event
return this.fetchDataAsync()
.then(() => {
// do something with the fetched data and continue to next click
});
}
});
binding.addWidgetEvents(widget, {
loaded: () => {
return false; // prevent firing events that were armed later.
}
});
Parameters:
| Name | Type | Description |
|---|---|---|
widget |
module:bajaux/Widget | |
events |
object |
applyDegradeBehavior() → {Promise}
- Description:
Hide or disable the widget based on whether this binding is currently
degraded.
- Source:
Returns:
- Type
- Promise
getBindingList() → {module:bajaux/model/binding/BindingList}
- Description:
Every Binding belongs to a BindingList which contains all the other
Bindings that are also bound to its target.
- Source:
Returns:
- Type
- module:bajaux/model/binding/BindingList
getOrdTarget() → {module:baja/ord/OrdTarget|undefined}
- Source:
Returns:
the OrdTarget this Binding is bound to, or
undefined if unbound
- Type
- module:baja/ord/OrdTarget | undefined
getWidget() → {module:bajaux/Widget}
- Source:
Returns:
the Widget this Binding is bound to
- Type
- module:bajaux/Widget
isBound() → {boolean}
- Source:
Returns:
if the binding is successfully bound to an
OrdTarget.
- Type
- boolean
isDegraded() → {boolean}
- Source:
Returns:
if the binding is unusable for any reason. The default
implementation returns !this.isBound().
- Type
- boolean
provide(name, cx) → {*|null|Promise.<(*|null)>}
- Description:
Given a certain property name, typically a Widget property, provide the
corresponding value for that name. This is roughly analogous to
BBinding#getOnWidget.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | the name of the property to retrieve a value for |
cx |
object | user context |
Returns:
by default, returns null which
indicates there is no value to be provided by this name. Override in
subclasses.
- Type
- * | null | Promise.<(*|null)>
removeListeners(widget)
- Description:
Any event handlers that would not automatically be cleaned up by
widget.destroy()can be explicitly cleaned up here.By default, this will clean up any events that were added via
addWidgetEvents().
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
widget |
module:bajaux/Widget |
requestRebind()
- Description:
Fires an event to signal to the framework that the binding is now bound to
a different target ORD. The framework should resolve the Binding's new
ORD, set a brand-new OrdTarget, and refresh its bound Widget so the UI is
brought up to date.Should not be overridden without calling
super().
- Source:
requestRefresh()
- Description:
Fires an event to signal that the Binding has new values to provide. The
framework should propagate all the Binding's properties to its bound
Widget so the UI is brought up to date.Should not be overridden without calling
super().
- Source:
save() → {*|Promise}
- Description:
Callback that will be called when the Px page containing this Binding is
saved. Each Binding will have a chance to save any user-entered data (it
is the Binding's responsibility to check if the user has made any changes
or not).
- Source:
Returns:
to be resolved when the binding has saved any
user-entered data
- Type
- * | Promise
setWidget(widget)
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
widget |
module:bajaux/Widget | the Widget this Binding is bound to |
targetChanged() → {Promise}
- Description:
This is a callback that will be run whenever the Binding is updated to
point to a new OrdTarget. This may happen when the binding's ORD changes,
or when it is re-resolved.
- Source:
Returns:
- Type
- Promise