source: Dev/trunk/src/client/qed-client/widgets/_ComplexValueMixin.js @ 461

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

Save answers, improved response page and question widgets.

  • Warn if _ComplexValueMixin is not pout on a form element, to prevent 'name' collisions. Changed all depending widgets to <form>'s.
  • Fixed names for question widgets to actually save answers.
  • Fixed and improved response page.
  • Fixed names in MultipleChoice? widget, which behaves different for radio and check.
File size: 2.0 KB
Line 
1define([
2    "dijit/_Container",
3    "dijit/form/_FormMixin",
4    "dojo/_base/array",
5    "dojo/_base/declare",
6    "dojo/_base/event"
7], function(_Container, _FormMixin, array, declare, event) {
8    return declare([_Container,_FormMixin],{
9        name: "",
10        value: null,
11        disabled: false,
12        readOnly: false,
13        postCreate: function() {
14            this.inherited(arguments);
15            if ( this.domNode.tagName.toLowerCase() !== "form" ) {
16                console.warn("Not scoping a _ComplexValueMixin in a form element can cause name clashes. E.g. radio buttons might stop working correctly. It is recommended to use <form> as the root element in your template for "+this.declaredClass+".");
17            }
18        },
19        _setDisabledAttr: function(value) {
20            this._set("disabled", value);
21            array.forEach(this._getDescendantFormWidgets(), function(child){
22                child.set("disabled", value);
23            });
24        },
25        _setReadOnlyAttr: function(value) {
26            this._set("readOnly", value);
27            array.forEach(this._getDescendantFormWidgets(), function(child){
28                child.set("readOnly", value);
29            });
30        },
31        focus: function() {
32            var children = this._getDescendantFormWidgets();
33            if ( children.length > 0 ) {
34                children[0].focus();
35            }
36        },
37        onSubmit: function(e) {
38            // since this widget is used to create more complex
39            // widgets within other forms, the onSubmit must either be
40            // ignored or propagated, but not handled here.
41            if ( e ) { event.stop(e); }
42            return false;
43        },
44        _onSubmit: function(e) {
45            // since this widget is used to create more complex
46            // widgets within other forms, the onSubmit must either be
47            // ignored or propagated, but not handled here.
48            if ( e ) { event.stop(e); }
49            return false;
50        }
51    });
52});
Note: See TracBrowser for help on using the repository browser.