Skip to content

Instantly share code, notes, and snippets.

@biodigitals
Created February 4, 2014 13:44
Show Gist options
  • Select an option

  • Save biodigitals/8803795 to your computer and use it in GitHub Desktop.

Select an option

Save biodigitals/8803795 to your computer and use it in GitHub Desktop.
// static/modules/application/my_component.js
App.MyComponentView = Backbone.View.extend({
// component wrapping your features
el: "#mycomponent",
events:{
'click #mybutton':'myMethod'
},
prepare:function(){
// init code for component
},
update: function(){
// update component view here
},
myMethod:function(e){
// what happens when user clicks my button ?
}
});
// and at the end of the page ...
<script>
App.myComponentView = new App.MyComponentView();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment