javaScript select box none을 선택할 때 Yui 3에서 필요합니까?
문제
누군가가 "모두 선택"또는 "선택 없음"을 클릭 한 다음 SelectBox에 각각 모든 항목을 선택하거나 모든 항목을 선택하지 않도록 YUI 3을 사용하고 있습니다. 내 코드는 다음과 같습니다.
// This selects all
Y.on('click',function (e) {
selectBoxNode.get("options").each(function () {
this.removeAttribute('selected');
this.setAttribute('selected','selected');
});
}, selectAllNode
);
// This selects none
Y.on('click',function (e) {
selectBoxNode.get("options").each(function () {
this.setAttribute('selected','false');
this.removeAttribute('selected');
});
selectBoxNode.('selectedIndex',-1);
}, selectNoneNode
);
SelectAllLink, SelectNonElink 및 SelectBoxNode는 자명하고 올바르게 반환 된 노드입니다. 업데이트 : SelectAll Works에서 각각의 '선택된'속성을 수동으로 제거하고 다시 설명해야했습니다.
SelectNoneLink는 작동하지 않습니다. 선택하지 않은 요소 만 선택 해제합니다 ... DOM 검사는 선택한 index 속성이 실제로 -1로 변경되었음을 보여 주지만 새로 고침이 필요할 수 있습니까?
모든 도움이 감사하겠습니다. 이것이 모든 프레임 워크에서 발생한다면, 또한 알아두면 좋을 것입니다.
감사!
해결책
이것은 나를 위해 효과가있었습니다.
YUI().use('node', function(Y) {
Y.get('#unsel').on('click', function(e) {
Y.get('select').get('options').set('selected',false);
});
Y.get('#sel').on('click', function(e) {
Y.get('select').get('options').set('selected', true );
});
});
제휴하지 않습니다 StackOverflow