Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6528

Show
Ignore:
Timestamp:
04/16/07 00:49:54 (1 year ago)
Author:
mislav
Message:

setValue:

- basic unit tests;
- multiple select boxes can now be given a single element, not just array;
- select boxes are still settable only by means of indexes :(

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/prototype/branches/form/src/form.js

    r6527 r6528  
    229229    var values, length = element.length; 
    230230    if (!length) return null; 
     231    if (indexes !== undefined && indexes.constructor != Array) indexes = [indexes]; 
    231232     
    232233    for (var i = 0, values = []; i < length; i++) { 
  • spinoffs/prototype/branches/form/test/unit/form.html

    r6526 r6528  
    385385        }); 
    386386      }); 
     387    }}, 
     388 
     389    testSetValue: function(){ with(this) { 
     390      // text input 
     391      var input = $('input_enabled'); 
     392      input.setValue('foo'); 
     393      assertEqual('foo', input.getValue()); 
     394      input.setValue(input.getAttribute('value')); 
     395      // checkbox 
     396      input = $('checkbox_hack'); 
     397      input.setValue(false); 
     398      assertEqual(null, input.getValue()); 
     399      input.setValue(true); 
     400      assertEqual("1", input.getValue()); 
     401      // selectbox 
     402      input = $('form_selects')['vu']; 
     403      input.setValue(2); 
     404      assertEqual('3', input.getValue()); 
     405      input.setValue(0); 
     406      assertEqual('1', input.getValue()); 
     407      // multiple select 
     408      input = $('form_selects')['vm[]']; 
     409      input.setValue([1, 2]); 
     410      assertEnumEqual(['2', '3'], input.getValue()); 
     411      input.setValue(0); 
     412      assertEnumEqual(['1'], input.getValue()); 
     413      input.setValue([0, 2]); 
     414      assertEnumEqual(['1', '3'], input.getValue()); 
    387415    }} 
    388416