Skip to content

Instantly share code, notes, and snippets.

@AleeRojas
Created December 12, 2015 11:26
Show Gist options
  • Save AleeRojas/8af897d690b61b828771 to your computer and use it in GitHub Desktop.
Save AleeRojas/8af897d690b61b828771 to your computer and use it in GitHub Desktop.
<script id="courseList" type="text/x-handlebars-template"> <span id="course-option" class="course-opt" value="{{id}}">{{name}}</span> </script>
method: in main.js
window.templates = function(id) { return Handlebars.compile($('#' + id).html(), context); };
then some of my code in my view
`App.Views.CourseView = Backbone.View.extend({
tagName: 'option',
className: 'course',
template: templates('courseList'),
// template: Handlebars.compile($('<span id="course-option" class="course-opt" value="{{id}}">{{name}}</span>').html()),
render: function() {
// var template = this.template(this.model.toJSON());
this.$el.html(this.template(this.model.toJSON()));
return this;
},
selection: function () {
console.log('course change');
}
});`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment