dojox/mvc/Bind (version 1.10)

See the dojox/mvc/Bind reference documentation for more information.

Method Summary

Methods

_Container()
_Controller()
_DataBindingMixin()
_InlineTemplateMixin()
at(target,targetProp)
Defined by dojox/mvc/at

Returns a pointer to data binding target (a dojo/Stateful property), called at handle, which is used for start synchronization with data binding source (another dojo/Stateful property).

Typically used in data-dojo-props so that a widget can synchronize its attribute with another dojo/Stateful, like shown in the example.

Parameter Type Description
target dojo/Stateful | String

dojo/Stateful to be synchronized.

targetProp String

The property name in target to be synchronized.

Returns:any | dojox/mvc/at.handle

A pointer to data binding target (a dojo/Stateful property), called at handle, which is used for start synchronization with data binding source (another dojo/Stateful property).

Examples

Example 1

Two seconds later, the text box changes from "Foo" to "Bar" as the "value" property in model changes.

<html>
    <head>
        <script src="/path/to/dojo-toolkit/dojo/dojo.js" type="text/javascript" data-dojo-config="parseOnLoad: 0"></script>
        <script type="text/javascript">
            require([
                "dojo/parser", "dojo/Stateful", "dijit/form/TextBox", "dojo/domReady!"
            ], function(parser, Stateful){
                model = new Stateful({value: "Foo"});
                setTimeout(function(){ model.set("value", "Bar"); }, 2000);
                parser.parse();
            });
        </script>
    </head>
    <body>
        <script type="dojo/require">at: "dojox/mvc/at"</script>
        <input type="text" data-dojo-type="dijit/form/TextBox" data-dojo-props="value: at(model, 'value')">
    </body>
</html>

Example 2

Edit in text box is reflected to the text next to it.

<html>
    <head>
        <script src="/path/to/dojo-toolkit/dojo/dojo.js" type="text/javascript" data-dojo-config="parseOnLoad: 0"></script>
        <script type="text/javascript">
            require([
                "dojo/parser", "dojo/Stateful", "dojo/domReady!"
            ], function(parser, Stateful){
                model = new Stateful({value: "Foo"});
                parser.parse();
            });
        </script>
    </head>
    <body>
        <script type="dojo/require">at: "dojox/mvc/at"</script>
        <input type="text" data-dojo-type="dijit/form/TextBox" data-dojo-props="value: at(model, 'value')">
        <span data-dojo-type="dijit/_WidgetBase" data-dojo-props="_setValueAttr: {node: 'domNode', type: 'innerText'}, value: at(model, 'value')"></span>
    </body>
</html>
bind(source,sourceProp,target,targetProp,func,bindOnlyIfUnequal)
Defined by dojox/mvc/Bind

Bind the specified property of the target to the specified property of the source with the supplied transformation.

Parameter Type Description
source dojo/Stateful

The source dojo/Stateful object for the bind.

sourceProp String

The name of the source's property whose change triggers the bind.

target dojo/Stateful

The target dojo/Stateful object for the bind whose property will be updated with the result of the function.

targetProp String

The name of the target's property to be updated with the result of the function.

func Function
Optional

The optional calculation to be performed to obtain the target property value.

bindOnlyIfUnequal Boolean
Optional

Whether the bind notification should happen only if the old and new values are unequal (optional, defaults to false).

Returns:undefined
bindInputs(sourceBindArray,func)
Defined by dojox/mvc/Bind

Bind the values at the sources specified in the first argument array such that a composing function in the second argument is called when any of the values changes.

Parameter Type Description
sourceBindArray dojo/Stateful[]

The array of dojo/Stateful objects to watch values changes on.

func Function

The composing function that is called when any of the source values changes.

Returns:Array
EditModelRefController()
EditStoreRefController()
EditStoreRefListController()
Element()
Defined by dojox/mvc/Element
equals(dst,src,options)
Defined by dojox/mvc/equals

Compares two dojo/Stateful objects, by diving into the leaves.

Recursively iterates and compares stateful values.

Parameter Type Description
dst Anything

The stateful value to compare with.

src Anything

The stateful value to compare with.

options dojox/mvc/equalsOptions

The object that defines how two stateful values are compared.

Returns:Boolean | undefined

True if dst equals to src, false otherwise.

Generate()
Defined by dojox/mvc/Generate
getPlainValue(value,options)

Create a raw value from a dojo/Stateful object.

Recursively iterates the stateful value given, and convert them to raw ones.

Parameter Type Description
value Anything

The stateful value.

options dojox/mvc/getPlainValueOptions

The object that defines how plain value should be created from stateful value.

Returns:any | undefined

The converted value.

getStateful(value,options)

Create a dojo/Stateful object from a raw value.

Recursively iterates the raw value given, and convert them to stateful ones.

Parameter Type Description
value Anything

The raw value.

options dojox/mvc/getStatefulOptions

The object that defines how model object should be created from plain object hierarchy.

Returns:Anything | undefined

The converted value.

Group()
Defined by dojox/mvc/Group
ListController()
ModelRefController()
newStatefulModel(args)
Defined by dojox/mvc/_base

Factory method that instantiates a new data model that view components may bind to.

Factory method that returns a client-side data model, which is a tree of dojo/Stateful objects matching the initial data structure passed as input:

  • The mixin property "data" is used to provide a plain JavaScript object directly representing the data structure.
  • The mixin property "store", along with an optional mixin property "query", is used to provide a data store to query to obtain the initial data.

This function returns an immediate dojox.mvc.StatefulModel instance or a Promise for such an instance as follows:

  • if args.data: returns immediately
  • if args.store: if store returns immediately, this function returns immediately; if store returns a Promise, this function returns a model Promise
Parameter Type Description
args Object

The mixin properties.

Output()
Defined by dojox/mvc/Output
Repeat()
Defined by dojox/mvc/Repeat
resolve(target,parent)
Defined by dojox/mvc/resolve

Find a dojo/Stateful for the target.

If target is not a string, return target itself. If target is "widget:widgetid", returns the widget whose ID is widgetid. If target is "rel:object.path", or target is other string, returns an object under parent (if specified) or under global scope.

Parameter Type Description
target dojo/Stateful | String

The data binding to resolve.

parent dojo/Stateful
Optional

The parent data binding. Used when the data binding is defined inside repeat.

Returns:undefined
StatefulArray(a)

An inheritance of native JavaScript array, that adds dojo/Stateful capability.

Supported methods are:

  • pop() - watchElements() notification is done for the removed elements. watch() notification is done for the length.
  • push() - watchElements() notification is done for the added elements. watch() notification is done for the length.
  • reverse() - watchElements() notification is done, indicating that the change affects all elements.
  • shift() - watchElements() notification is done for the removed elements. watch() notification is done for the length.
  • sort() - watchElements() notification is done, indicating that the change affects all elements.
  • splice() - watchElements() notification is done for the removed/added elements. watch() notification is done for the length. Returns an instance of StatefulArray instead of the native array.
  • unshift() - watchElements() notification is done for the added elements. watch() notification is done for the length.
  • concat() - Returns an instance of StatefulArray instead of the native Array.
  • join() - The length as well as the elements are obtained via stateful getters, instead of direct access.
  • slice() - The length as well as the elements are obtained via stateful getters, instead of direct access.
  • Setting an element to this array via set() - watch() notification is done for the new element as well as the new length.
  • Setting a length to this array via set() - watchElements() notification is done for the removed/added elements. watch() notification is done for the new length.
Parameter Type Description
a Anything[]
Returns:undefined
StatefulModel()
StatefulSeries()
StoreRefController()
sync(source,sourceProp,target,targetProp,options)
Defined by dojox/mvc/sync

Synchronize two dojo/Stateful properties.

Synchronize two dojo/Stateful properties.

Parameter Type Description
source dojo/Stateful

Source dojo/Stateful to be synchronized.

sourceProp String

The property name in source to be synchronized.

target dojo/Stateful

Target dojo/Stateful to be synchronized.

targetProp String

The property name in target to be synchronized.

options dojox/mvc/sync.options

Data binding options.

Returns:any | object

The handle of data binding synchronization.

Templated()
Defined by dojox/mvc/Templated
WidgetList()
Error in the documentation? Can’t find what you are looking for? Let us know!