Changeset 1804


Ignore:
Timestamp:
2011-01-03 13:12:12 (2 years ago)
Author:
karel
Message:

Remove values that are no longer in the option list

fixes #384

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/kauri-forms/kauri-forms-extra/src/main/kauri/static/dblselect/js/dblselect.js

    r1633 r1804  
    201201      this.refreshButtonsState(); 
    202202      this.refreshAddOtherButtonState(); 
    203   } 
     203    } 
     204 
     205    DoubleSelectControl.prototype.normaliseValue = function (value) { 
     206        var options = this.options.getValues(); 
     207        var optionValues = {}; 
     208        for (var i = 0; i < options.length; i++) { 
     209          optionValues[options[i]] = 1; 
     210        } 
     211 
     212        if (value) { 
     213          var newValue = []; 
     214          for (var i = 0; i < value.length; i++) { 
     215            var val = value[i]; 
     216 
     217            if (optionValues[val]) { 
     218              newValue.push(val); 
     219            } 
     220          } 
     221          return newValue; 
     222        } 
     223    } 
    204224 
    205225    DoubleSelectControl.prototype.readUserValue = function() { 
     
    221241         
    222242        this.userValueLabelMap = {}; 
     243        var optionValues = {}; 
    223244        for (var i = 0; i < userValues.length; i++) { 
    224245          this.userValueLabelMap[userValues[i]] = labels[i]; 
     246          optionValues[userValues[i]] = 1; 
    225247        } 
    226248 
    227249        var $available = this.getElement("available"); 
    228250        if ($available) { 
     251            this.setValue(this.getValue()); 
    229252            this.refreshAvailableSelect(); 
    230253            this.refreshSelectedSelect(); 
Note: See TracChangeset for help on using the changeset viewer.