source: Dev/branches/rest-dojo-ui/client/rft/ui/_Page.js @ 356

Last change on this file since 356 was 354, checked in by tjcschipper, 13 years ago
  • Made change to _Page.js to destroy the page's child widgets on page leave. This was causing widgets with identical names (such as "btnSave") to make regsitry throw a duplicate widget error.
  • survey.js/html now sorts loaded questions into categories and topics and creates or adds them to the proper TabPane/Selectors?. TODO: Allow for spaces in category titles.
  • Added "addQuestion()" method to Selector.js, to internalize question visualization logic.
  • Included surveyAdvanced page in run.js
  • Changes index to use proper button format, still need to figure out a way to bind content.goTo to the onclick field (since there is no index.js script being run!)
  • Various css tweaks.
File size: 2.1 KB
Line 
1define(['dojo/_base/declare','dojo/_base/lang','dojo/parser','dojo/query',
2    'dojo/dom-attr','dijit','dijit/_WidgetBase'],
3    function(declare,lang,parser,query,attr,dijit,_WidgetBase){
4        return declare('rft.ui._Page',[_WidgetBase],{
5            startup: function() {
6                this.inherited(arguments);
7                this._attachPointsAndEvents();
8                this.onVisit();
9            },
10            _attachPointsAndEvents: function() {
11                query('*[data-rft-attach-point]'/*, this.domNode*/).forEach(lang.hitch(this,function(node){
12                    var point = attr.get(node,'data-rft-attach-point');
13                    var widget = dijit.byId(attr.get(node,'id'));
14                    this[point] = widget || node;
15                }));
16                query('*[data-rft-attach-event]'/*, this.domNode*/).forEach(lang.hitch(this,function(node){
17                    var event = attr.get(node,'data-rft-attach-event').split(':');
18                    var eventName = event[0];
19                    var eventHandler = event[1];
20                    var widget = dijit.byId(attr.get(node,'id'));
21                    if ( widget ) {
22                        this.connect(widget,eventName,lang.hitch(this,eventHandler));
23                    } else {
24                        this.connect(node,eventName,lang.hitch(this,eventHandler));
25                    }
26                }));
27                query('> script[type^="rft/method"]',this.domNode)
28                .orphan().forEach(lang.hitch(this,function(s){
29                    var methodName = s.getAttribute("data-rft-method");
30                    var func = parser._functionFromScript(s);
31                    this[methodName] = func;
32                }));
33            },
34            /** Event fired after startup of all widgets is complete */
35            onVisit: function(){},
36            /** Event fired before leaving the page. Return false to prevent */
37            onLeave: function(){
38                dijit.findWidgets(this.domNode).forEach(function(w){
39                    w.destroyRecursive(false);
40                });
41            }
42        });
43    });
Note: See TracBrowser for help on using the repository browser.