Created
May 29, 2013 16:28
-
-
Save tvpmb/5671658 to your computer and use it in GitHub Desktop.
Backbone.js View, Event and Method Pattern, using require.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define([ | |
| //"modules/tvpmodule/tvpview", | |
| ], | |
| function() { | |
| // Simple events mapping | |
| var Events = { | |
| "click .selector": "handleClick" | |
| }; | |
| return Events; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define([ | |
| "modules/tvpmodule/tvpview", | |
| "modules/tvpmodule/tvpmodel", | |
| "modules/module/views/view.events", | |
| "modules/module/views/view.methods", | |
| ], | |
| function(TVPView, TVPModel, Events, Methods) { | |
| var View = TVPView.extend({ | |
| template: "facebook/fb_pagetab_done", | |
| className: "container", | |
| beforeRender: function() { | |
| var fbPageId = this.data.sessionModel.get('fbPageId'); | |
| if (!(fbPageId > 0)) { | |
| return false; | |
| } | |
| this.data.pageTabPageModel.id = fbPageId; | |
| var pageTabFetch = this.data.pageTabPageModel.fetch(); | |
| pageTabFetch.done(function(data) { | |
| console.log('fetch',data); | |
| }); | |
| var ytUserId = this.data.sessionModel.get('importUserId'); | |
| if (!ytUserId || !(ytUserId.length > 0)) { | |
| this.model.set({ | |
| completeText: 'The TVPage that you have selected has been set.' | |
| }, { silent: true }); | |
| return false; | |
| } | |
| console.log(this.data.pageTabIdModel, this.data.pageTabPageModel); | |
| //this.startImport(); | |
| }, | |
| initialize: function() { | |
| } | |
| }); | |
| return View; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define([ | |
| //"modules/tvpmodule/tvpview", | |
| ], | |
| function() { | |
| // Event Methods | |
| var Methods = { | |
| handleClick: function() { | |
| return true; | |
| } | |
| }; | |
| return Methods; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment