Skip to content
This repository was archived by the owner on Dec 9, 2021. It is now read-only.

Commit 27bd2e8

Browse files
committed
update example
1 parent 07f7d1e commit 27bd2e8

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

examples/SinglePageWebsite/assets/scripts/view/RootView.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ define(function (require, exports, module) { // jshint ignore:line
6262
this.addChild(this._footerView);
6363

6464
Router.add('', this.homeRouterHandler, this);
65-
Router.add('about', this.aboutRouterHandler, this);
66-
Router.add('contact', this.contactRouterHandler, this);
67-
Router.add('services', this.servicesRouterHandler, this);
68-
Router.add('menu', this.menuRouterHandler, this);
69-
Router.add(':all:', this._allRouterHandler, this);
65+
Router.add('/menu/', this.menuRouterHandler, this);
66+
Router.add('/about/', this.aboutRouterHandler, this);
67+
Router.add('/services/', this.servicesRouterHandler, this);
68+
Router.add('/contact/?', this.contactRouterHandler, this);
69+
Router.add('*', this._allRouterHandler, this);
7070
Router.start();
7171
};
7272

@@ -119,34 +119,44 @@ define(function (require, exports, module) { // jshint ignore:line
119119
};
120120

121121
RootView.prototype.homeRouterHandler = function (routerEvent) {
122+
console.log("routerEvent", routerEvent);
123+
122124
if (!(this._currentView instanceof HomeView)) {
123125
var view = new HomeView();
124126
this.changeView(view);
125127
}
126128
};
127129

128130
RootView.prototype.aboutRouterHandler = function (routerEvent) {
131+
console.log("routerEvent", routerEvent);
132+
129133
if (!(this._currentView instanceof AboutView)) {
130134
var view = new AboutView();
131135
this.changeView(view);
132136
}
133137
};
134138

135139
RootView.prototype.contactRouterHandler = function (routerEvent) {
140+
console.log("routerEvent", routerEvent);
141+
136142
if (!(this._currentView instanceof ContactView)) {
137-
var view = new ContactView();
143+
var view = new ContactView(routerEvent);
138144
this.changeView(view);
139145
}
140146
};
141147

142148
RootView.prototype.servicesRouterHandler = function (routerEvent) {
149+
console.log("routerEvent", routerEvent);
150+
143151
if (!(this._currentView instanceof ServicesView)) {
144152
var view = new ServicesView();
145153
this.changeView(view);
146154
}
147155
};
148156

149157
RootView.prototype.menuRouterHandler = function (routerEvent) {
158+
console.log("routerEvent", routerEvent);
159+
150160
if (!(this._currentView instanceof MenuView)) {
151161
var view = new MenuView();
152162
this.changeView(view);

examples/SinglePageWebsite/assets/scripts/view/contact/ContactView.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,22 @@ define(function (require, exports, module) { // jshint ignore:line
1717

1818
var _super = Extend(ContactView, DOMElement);
1919

20-
function ContactView() {
20+
function ContactView(routerEvent) {
2121
_super.call(this);
22+
23+
/**
24+
* @property _routeEvent
25+
* @type {RouteEvent}
26+
* @private
27+
*/
28+
this._routeEvent = routerEvent;
2229
}
2330

2431
/**
2532
* @overridden DOMElement.createChildren
2633
*/
2734
ContactView.prototype.createChildren = function () {
28-
_super.prototype.createChildren.call(this, ContactTemplate);
35+
_super.prototype.createChildren.call(this, ContactTemplate, this._routeEvent.query);
2936

3037
// Create and add your child objects to this parent class.
3138
};

examples/SinglePageWebsite/assets/templates/contact/ContactTemplate.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ <h2>Contact the <span>DelliStore!</span></h2>
1010
<ul>
1111
<li>
1212
<label>Full Name <span>*</span></label>
13-
<input type="text" />
13+
<input type="text" value="{{name}}" />
1414
</li>
1515
<li>
1616
<label>Email Address <span>*</span></label>
17-
<input type="text" />
17+
<input type="text" value="{{email}}" />
1818
</li>
1919
<li>
2020
<label>Your Message <span>*</span></label>
21-
<textarea cols="50" rows="5"></textarea>
21+
<textarea cols="50" rows="5">{{message}}</textarea>
2222
</li>
2323
<li class="submit">
2424
<p><span>*</span> These are required fields</p>

examples/SinglePageWebsite/assets/templates/header/HeaderTemplate.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ <h1><a href="#/">DelliStore</a></h1>
66
<li><a href="#/menu/">Menu</a></li>
77
<li><a href="#/about/">About Us</a></li>
88
<li><a href="#/services/">Services</a></li>
9-
<li><a href="#/contact/">Contact Us</a></li>
9+
<li><a href="#/contact/?name=robert&email=email@email.com&message=Robert is so cool.">Contact Us</a></li>
1010
</ul>
1111
</div>
1212
</div>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy