source: Dev/trunk/client/qed/model/widgets/questions/MultipleChoiceInputWidget.js @ 441

Last change on this file since 441 was 441, checked in by hendrikvanantwerpen, 12 years ago

Big cleanup of the question content.

  • Replaced old list implementations with a new one that behaves like a form widget.
  • All question content is now in separate widgets, not in the factory itself.
  • Added form and widget validation for question editing.
File size: 1.1 KB
Line 
1define([
2    "../../../widgets/_ComplexValueWidget",
3    "dijit/form/CheckBox",
4    "dijit/form/RadioButton",
5    "dojo/_base/array",
6    "dojo/_base/declare",
7    "dojo/dom-construct",
8    "dojo/text!./templates/MultipleChoiceInputWidget.html"
9], function(_ComplexValueWidget, CheckBox, RadioButton, array, declare, domConstruct, template) {
10    return declare([_ComplexValueWidget],{
11        templateString: template,
12        startup: function() {
13            if ( this._started ) { return; }
14            this.inherited(arguments);
15
16            domConstruct.empty(this.domNode);
17            var Ctor = this.allowMultiple === true ? CheckBox : RadioButton;
18            array.forEach(this.items, function(item, index){
19                var div = domConstruct.create("div", {
20                }, this.domNode, "last");
21                var input = new Ctor({
22                    name: index.toString()
23                }).placeAt(div);
24                var label = domConstruct.create("label",{
25                    innerHTML: item.text
26                }, div);
27            }, this);
28        }
29    });
30});
Note: See TracBrowser for help on using the repository browser.