!!! Listing aus dem Artikel "Javascript-Knigge" von Stefan Minter
!!! in iX 6/2006, S. 72
!!! Listing 1: input mit onkeyup
!!! Listing 2: CSS mit Verhaltenscode
#input {
onkeyup: "if (this.value.length > 1) {loadAcroList(this.value);}";
onblur: "if (this.value.length < 2) {loadAcroList(this.value);}";
}
input[type=radio][name=typ] {
onclick: "showAcroList()";
}
!!! Listing 3: Lösung mit Nolans Behaviour
var xmladRules = {
'#input' : function(element){
element.onkeyup = function(){
if (this.value.length > 1) {loadAcroList(this.value);}
}
element.onblur = function(){
if (this.value.length < 2) {loadAcroList(this.value);}
}
},
'input[type=radio][name=typ]' : function(element){
element.onclick = function(){
showAcroList()
}
}
};
Behaviour.register(xmladRules);
!!! Listing 4: Behaviour-Einbindung in HTML