Skip to content

Instantly share code, notes, and snippets.

@drewwells
Created September 19, 2012 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewwells/3753076 to your computer and use it in GitHub Desktop.
Save drewwells/3753076 to your computer and use it in GitHub Desktop.
The first file creates a new model and pairs it with a controller
var Facets = Spine.Controller.sub({
tag: "li",
events: {
"change": "click"
},
init: function(){
this.item.bind( "update", this.proxy( this.render ));
},
render: function(){
this.html( Mustache.to_html(searchFacetTmpl,this.item) );
!this.item.count ? this.$el.addClass('empty') : this.$el.removeClass('empty');
},
click: function(){
//This code works
//Facet.find(this.item.cid).updateAttribute( 'checked', this.el.find('input').prop('checked') == 1 );
//This code affects permanent changes on my model
this.item.updateAttribute( 'checked', this.el.find('input').prop('checked') == 1 );
}
});
var typeFacet = Facet.create({
id: type.filter,
filter: type.filter,
title: type.title,
checked: type.checked,
count: type.count,
type: 'type'
});
typeFacet.save();
new Facets({
item: typeFacet,
el: $jsFilterPanel.find( ".js-" + typeFacet.id )
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment