Changeset 1376

Show
Ignore:
Timestamp:
20/11/09 14:53:16 (3 months ago)
Author:
karel
Message:

Bugfix: $acinput was getting global scope, causing problems when multiple autocomplete controls were active

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/modules/kauri-forms/kauri-forms-extra/src/main/kauri/static/autocomplete/js/autocomplete.js

    r1375 r1376  
    4343 
    4444    AutocompleteControl.prototype.initElements = function(create) { 
    45         $acinput = kf.ControlElements.lookup(this, "acinput", true); 
     45        this.$acinput = kf.ControlElements.lookup(this, "acinput", true); 
    4646 
    4747        var me = this; 
     
    6767        } 
    6868         
    69         $acinput.autocomplete(this.dataUri, jqOptions).bind("result", function(event, objData, valueData) { 
     69        this.$acinput.autocomplete(this.dataUri, jqOptions).bind("result", function(event, objData, valueData) { 
    7070          me.setValue(objData); 
    7171        }); 
     
    8888    AutocompleteControl.prototype.setValue = function(value) { 
    8989        this["<super.call>"]("setValue", [value]); 
    90         if (value === undefined) { 
    91           $acinput.val(); 
    92         } else { 
    93           //$acinput.val(this.inputTemplate.expand(value, true)); 
    94         } 
    9590    } 
    9691 
    9792    AutocompleteControl.prototype.getWireValue = function() { 
    98       var t = this.getValue(); 
    99       var s = JSON.stringify(t); 
    10093      return JSON.stringify(this.getValue()); 
    10194    } 
     
    10497      if (wireValue === undefined) { 
    10598        this.setValue(undefined); 
    106         $acinput.val(''); 
     99        this.$acinput.val(''); 
    107100      } else { 
    108101        this.setValue(JSON.parse(wireValue)); 
    109         $acinput.val(this.inputTemplate.expand(this.getValue(), true)); 
     102        this.$acinput.val(this.inputTemplate.expand(this.getValue(), true)); 
    110103      } 
    111104    } 
  • trunk/samples/kauri-forms-sample/src/main/kauri/pages/autocomplete-control.html.xml

    r1375 r1376  
    33      t:inherit="module:/templates/layout/layout.xml"> 
    44 
    5   <t:block name="title">Selection control sample</t:block> 
     5  <t:block name="title">Autocomplete control sample</t:block> 
    66 
    77  <t:block name="extra-headers"> 
     
    1616                  "base": "string", 
    1717                  "label": "Select a contact", 
     18                  "control": { 
     19                      "base": "autocomplete-control", 
     20                      "dataUri": "${publicUri('service:/data/contact/')}", 
     21                      "inputTemplate": "input:{id} - {name}", 
     22                      "listTemplate": "list:{id} - {name} {email}" 
     23                  } 
     24              }, 
     25              "another": { 
     26                  "base": "string", 
     27                  "label": "Select another contact", 
    1828                  "control": { 
    1929                      "base": "autocomplete-control", 
     
    4353        </dl> 
    4454 
     55        <dl kauri-idref="another"> 
     56          <dt><label kauri-role="label"/></dt> 
     57          <dd><input type="text" kauri-role="acinput"/></dd> 
     58        </dl> 
     59 
    4560      </fieldset> 
    4661    </form>