... 여전히 다소 미개척 지상의 말 Higgins의 위젯은 위젯 내의 예 (http://higginsforpresident.net/2010/01/widgets-within-widgets)입니다. 나는 기본 위젯의 이름을 'telliott'로 바꿨다.
는
RadioContainer
일부 JS 코드가 (분명히 당신이 XHR 호출 또는 어떤에서 사전에 라벨의 배열을 만들 수 있습니다)
<script type="text/javascript">
dojo.require('telliott.RadioContainer');
dojo.addOnLoad(function() {
var container1 = new telliott.RadioContainer({
id: 'Container1',
name: 'Container1',
labels: ['one', 'two', 'three', 'The quick brown fox', 'Jumped over the lazy dog', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'Mauris vitae nunc non risus commodo sodales', 'Maecenas sed nibh et turpis laoreet volutpat at et sapien'],
selected: 'two',
}).placeAt(dojo.byId('container'));
});
</script>
를 호출합니다 'RadioContainer'을 만들려면 :
를
dojo.provide('telliott.RadioContainer');
dojo.require('telliott.Widget');
dojo.require('dijit.form.RadioButton');
dojo.declare('telliott.RadioContainer', [telliott.Widget], {
templateString: dojo.cache('telliott', 'templates/RadioContainer.html'),
name: "",
postCreate: function() {
this.labels = this.labels || [];
this.name = this.name || "";
this.selected = this.selected || "";
this.labels.forEach(dojo.hitch(this, function(l) {
this.createRadio(l);
}));
},
createRadio: function(/* String */ label) {
var item = dojo.create('li', null, this.containerNode, 'last');
var nobr = dojo.create('nobr', null, item);
var radio = this.adopt(dijit.form.RadioButton, {
checked: this.selected == label ? true : false,
value: label,
name: this.name
});
radio.placeAt(nobr);
this.createLabel(label, radio.get('id'), nobr);
},
createLabel: function(/* String */ label, /* String */ idFor, /* Node */ location) {
dojo.create('label', { for: idFor, innerHTML: label }, location, 'last');
}
});
및 템플릿 :
<div class="dijit dijitReset RadioContainer">
<ul dojoAttachPoint="containerNode" class="dijit dijitReset contents"></ul>
</div>
012 일부 CSS와 함께 3,516,
:
#Container1 {
width: 500px;
background-color: white;
}
내부적으로 위젯은 다음과 같습니다 위젯 자체를 만들 때
.claro .RadioContainer {
overflow-y: auto;
height: 100%;
}
.claro .RadioContainer .contents {
padding: 10px;
list-style: none;
}
, 당신은 다음 또한 지정해야합니다은 즉, 표준 CSS를 사용하여 인스턴스 당 폭의 정렬되지 않은 목록을 만들고, 라디오 버튼과 레이블을 <nobr>
태그로 묶고이를 목록의 항목으로 추가합니다.
원하는 경우이 데이터 저장소에 알리는 것이 매우 쉽습니다.
감사합니다. –