Created
September 19, 2012 23:47
-
-
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
This file contains 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
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 ); | |
} | |
}); |
This file contains 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
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