Skip to content

Instantly share code, notes, and snippets.

@JogoShugh
Last active December 15, 2015 17:59
Show Gist options
  • Save JogoShugh/5300295 to your computer and use it in GitHub Desktop.
Save JogoShugh/5300295 to your computer and use it in GitHub Desktop.
Extend Backone.Model to consume Azure resource
<h2>Details</h2>
<p><a href='{{support.href}}'>{{support.title}}</a></p>
<p><b>Cost:</b> {{cost}}</p>
<p>{{description}}</p>
<ul class='textLinks nav nav-tabs nav-stacked'>
{{#each textLinks}}
<li>
<a href="{{href}}">
<img src="img/{{type}}.png">
{{title}}
</a>
</li>
{{/each}}
</ul>
catalogApp.EntryModel = Backbone.Model.extend(url: ->
"http://appcatalog.azurewebsites.net/appcatalog/entries?staticId=" + @id
)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>VersionOne App Catalog</title>
<meta name="description" content="">
<meta name="author" content="">
<style>
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
</style>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/styles.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div class="row-fluid">
<div id="content" class="span12>"></div>
</div>
</div>
<script
data-main='scripts/main.js'
src='scripts/require.js'
type='text/JavaScript'>
</script>
</body>
</html>
requirejs.config shim:
handlebars:
exports: 'Handlebars'
'underscore-min':
exports: '_'
'backbone-min':
deps: ['underscore-min']
exports: 'Backbone'
'responsiveslides.min': ['jquery']
'bootstrap.min': ['jquery']
video: ['jquery']
define 'catalogApp', [], () ->
return {}
require [
'handlebars',
'jquery',
'moment',
'entryModel',
'catalogApp',
'entryViews',
'backbone-min',
'bootstrap.min',
'video',
'responsiveslides.min',
], (Handlebars, $, moment, EntryModel, catalogApp) ->
# etc
catalogApp.Router = Backbone.Router.extend({
routes:
"entries/:id": "entryDetails"
"": "home"
home: ->
this.entryDetails('v1clarityppm') # redirect to a known good id
entryDetails: (id) ->
entry = new catalogApp.EntryModel(id: "http://versionone.com/" + id)
entry.fetch success: ->
$("#content").html new catalogApp.EntryDetailsView(model: entry).render().el
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment