Hallo alle miteinander.
Ich habe ein hier ein Konstrukt, welches eine Art Select nachbaut, ich bin mit dem Ergebnis auch ganz zufrieden. Nur ein Problem stört mich noch:
Wenn das nachgebaute Select offen ist, muss dort etwas angeklickt werden, damit es sich schließt. Ich hätte das gerne wie bei einem echten Select, also das quasi beim bluren das Select zugeht.
Hier erstmal eswas Code (um unwesentliches gekürzt):
this.doShowSpecialSelect = function(original){
if(Display.selectWithSpecial!=null)
Display.hideSpecialSelect();
var temp = '<p id="ssoold" onclick="Display.hideSpecialSelect();" style="height:23px;white-space:nowrap;border:thin inset #DDDDDD;">'+
Display.specializedObject.options[Display.specializedObject.selectedIndex].text+
'<input onblur="setTimeout('Display.hideSpecialSelect()',100)" id="13erSpecialButton" type="button" style="height:18px;position:absolute;top:3px;right:2px;" value=">"></p>';
temp = temp + '<div style="border:1px solid #000000">';
for(var i=0; i<Display.specializedObject.options.length; i++){
temp = temp + '<p id="sso'+i+'" onclick="Display.processSpecialSelect(this)" onmouseover="Display.hoverSpecialOption(this)"' +
' onmouseout="Display.hoverSpecialOption(this)" style="white-space:nowrap;">' + Display.specializedObject.options[i].text + '</p>';
}
temp = temp + '</div>';
var coverDiv = document.getElementById('selectCoverFrame');
var specialDiv = document.getElementById('13er_special');
specialDiv.style.width = '20px';
specialDiv.style.top = getY(Display.specializedObject)-295;
specialDiv.style.left = getX(Display.specializedObject)-210;
specialDiv.style.display = 'block';
specialDiv.innerHTML = temp;
var subEntries = specialDiv.getElementsByTagName('p');
var targetWidth = 0;
for(var i=0; i<subEntries.length; i++){
if(jQuery(subEntries[i]).width() > targetWidth)
targetWidth = jQuery(subEntries[i]).width();
}
targetWidth = targetWidth+22;
document.getElementById('ssoold').style.width = targetWidth;
Display.selectWithSpecial = Display.specializedObject;
specialDiv.style.width = targetWidth;
specialDiv.style.position = 'absolute';
coverDiv.width = targetWidth;
coverDiv.height = (subEntries.length*14)+11;
coverDiv.style.position = 'absolute';
coverDiv.style.top = getY(Display.specializedObject)-295;
coverDiv.style.left = getX(Display.specializedObject)-210;
Display.specializedObject.style.display = 'none';
Display.specializedObject.disabled = true;
jQuery(document.getElementById("13erSpecialButton")).focus();
}
Diese Function wird beim onfocus eines Select aufgerufen, wie gesagt, alles funktioniert, bis auf das Fokussieren des Button. Im FF und Safari gehts btw.
Danke für anregungen und Ratschläge.