26.12.2014 Aufrufe

img - GitHub Pages

img - GitHub Pages

img - GitHub Pages

MEHR ANZEIGEN
WENIGER ANZEIGEN

Sie wollen auch ein ePaper? Erhöhen Sie die Reichweite Ihrer Titel.

YUMPU macht aus Druck-PDFs automatisch weboptimierte ePaper, die Google liebt.

3. Technische Architektur 34<br />

28 , 'community': 'createCommunity'<br />

29 //...<br />

30 }<br />

31<br />

32 /** Function: home<br />

33 * Home page which renders the login button if not authorized.<br />

34 * Otherwise it redirects to community/create or community/:slug/tasks.<br />

35 */<br />

36 , home: function home() {<br />

37 if(!this.isAuthorized()) {<br />

38 this.render(this.createView(HomeView));<br />

39 } else {<br />

40 var community = this.dataStore.get('community');<br />

41 if(!community) {<br />

42 this.navigate('community/create', { trigger: true });<br />

43 } else {<br />

44 this.navigate('community/' + community.get('slug') +<br />

45 '/tasks', { trigger: true });<br />

46 }<br />

47 }<br />

48 }<br />

49<br />

50 /** Function: createCommunity<br />

51 * Create community view<br />

52 */<br />

53 , createCommunity: function createCommunity() {<br />

54 debug('create community');<br />

55 if(!this.redirectIfNotAuthorized()) {<br />

56 this.render(this.createView(CreateCommunityView));<br />

57 }<br />

58 }<br />

59 //...<br />

60 });<br />

Quelltext 3.1: Auszug aus Router der Beispielapplikation [AJWq]<br />

Der Router aus Quelltext 3.1 wird sowohl vom Client als auch vom Server verwendet<br />

und registriert URLs mit den entsprechenden Funktionen.<br />

Die “HomeView” ist in Quelltext 3.2 zu sehen.<br />

7 module.exports = View.extend({<br />

8 el: '#main'<br />

9 , template: templates.login<br />

10<br />

11 /** Function: renderView<br />

12 * Renders the home view.<br />

13 */<br />

14 , renderView: function renderView() {<br />

15 this.$el.html(this.template({}));<br />

16 }<br />

17<br />

18 /** Function: afterRender

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!