Dojo Order method to keep count before actual value

Using Dojo 1.6.1.

Update: Here's a jsfiddle

The form is created with some fields.

this.projectServiceidField = new dijit.form.TextBox({
    label: 'idField'
    , name: 'project_service_id'
    , required: true
    , type: 'hidden'

this.projectServiceEquipmentSourceAddress = new dijit.form.FilteringSelect({
    name: 'source_address_id'
    , required: true
    , store: model.CustomerAddressesPairsView
    , searchAttr: "name"
    , style: "width: 40ex;"


The app should be notified when all the widget values ​​are set. To do this, a Deferred object is created with a Stateful clock on the Widget property. Deferred objects are all placed in the Deferred list. After the widget value has been initially set, the clock is removed and the Deferred object is resolved.

w.deferred = new dojo.Deferred();

// Watch the widget value
w.initWatch ='value', function(property, oldValue, newValue) {
    console.debug(, 'property:', property, 'oldValue:', oldValue,'newValue:', newValue,'w.get(\'value\'):', w.get('value'));

// Set the widget value
w.set('value', value);


var dl = new dojo.DeferredList(da);


When DeferredList is enabled, all widget values ​​must be set.

    function() {
        dojo.forEach(da, function(d) {
            console.debug(, d);

        console.debug(, dl, 'DeferredList resolved -------->', form.getValues());


But it doesn't work as expected. In particular, the fields that handle xhr. Here are the values ​​generated in value change events.

project_service_id property: value oldValue: newValue: 1025 w.get ('value'): 1025

source_address_id property: value oldValue: newValue: 59 w.get ('value'):

source_address_id should have been 59, but when I w.get ('value') it is not equal to newValue. Shouldn't they be?

How to determine when a widget value is set? Why not value == w.get ('value') right after w.set ('value', value)?

If w.set ('value', value) doesn't really set a value, shouldn't it return deferred ones?

Shouldn't you just watch the fire after the value has been set?

Dojo Versions:

Crash in Dojo 1.6.1. The clock doesn't always fire, and w.get ('value')! = NewValue when it does.

Crash less than Dojo 1.7.2. The clock still doesn't always fire, but at least w.get ('value') == newValue.


source to share

1 answer

after some discussion with richard on irc, we were able to figure out that there is some nuance between

and dijit.form.FilteringSelect

that prevents the callback from being triggered "value"

if the store has not yet executed fetch

. the working solution was to do first fetch

and then create the widget in the callback onComplete

- see

relevant part

    onComplete: function() {
        var w = new dijit.form.FilteringSelect({
            name: 'source_address_id',
            required: true,
            store: customerAddressesPairsView,
            searchAttr: "name",
            style: "width: 40ex;"
        }, 'sourceAddress');

        var handle =, oldValue, newValue) {
            console.log(property, oldValue, newValue);

        w.set("value", value1);
        console.debug('Value set to ' + value1);
        console.debug('Immediate get returns:', w.get('value'));
        console.debug('Direct access returns: ' + w.value);




All Articles