3.0.5

Revert AW.UI.Combo


How does one revert a AW.UI.Combo() back to its original value assuming it fails a test?

Given:
feeCombo.onItemSelectedChanged = function(value, index) {
    if ( value ) {
        if( myFeesClrs[index] == "noshow" ) {
            alert("ERROR: You cannot select a red item. This fee is not assessable at this location.");
            // what next?
        }
        document.getElementById("LocFeeCode").value = myFeesKeys[index];
    }
    else {
        prevIdx = index;
    }
};


I get to the error.
Paul Tiseo
May 1,
Well,

Some topics don't attract answers, huh? :) Here goes for posterity (a.k.a. forum searchers):

// Note: onItemSelectedChanging fires twice on change: 
// once with <value> = false where index is old selection
// and once with <value> = true where index is new selection
var prevIdx = -1;
feeCombo.onItemSelectedChanging = function(value, index) {
    if ( value ) {
        if( myFeesClrs[index] == "noshow" ) {
            alert( "ERROR: You cannot select a red item. This fee is not assessable at this location." );
            this.setCurrentItem( prevIdx );
            this.setCurrentValue( myFeesVals[prevIdx] );
            return 1; // using non-zero as error in AW; not sure if this is necessary or observed
        }
        document.getElementById("LocFeeCode").value = myFeesKeys[index];
    }
    else {
        prevIdx = index;
    }
};


Seems to work.

Paul Tiseo
May 2,

This topic is archived.

See also:


Back to support forum