Last active
November 6, 2015 02:46
-
-
Save kurtisdunn/09484c10cc8b9b5200d0 to your computer and use it in GitHub Desktop.
Backbone.js Views - Template Loader.
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
fetchTemplates: function() { | |
var that = this; | |
var templatesCollection = new TemplatesCollection(); | |
switch (window.location.pathname) { | |
case '/': | |
templatesCollection.fetch({ | |
url: '/api/template/home', | |
success: function(rsp) { | |
//Set Template | |
templateName = 'Home'; | |
that.renderMainContent(rsp.findWhere({ | |
'template_title': "Home" | |
})); | |
} | |
}); | |
break; | |
default: | |
templateName = window.location.pathname.toString(); | |
templatesCollection.fetch({ | |
url: '/api/template' + window.location.pathname, | |
success: function(rsp) { | |
templateName = window.location.pathname.substring(1); | |
that.renderMainContent(rsp.findWhere({ | |
'template_desc': window.location.pathname.substring(1) | |
})); | |
}, | |
}); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment