Skip to content

Instantly share code, notes, and snippets.

@yumike
Last active December 17, 2015 02:59
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 yumike/5539438 to your computer and use it in GitHub Desktop.
Save yumike/5539438 to your computer and use it in GitHub Desktop.
skel.js usage preview
class Item extends Backbone.Model
initialize: ->
@variants = new Backbone.Collection(@get('variants'))
class Items extends Backbone.Collection
url: '/api/items'
model: Item
parse: (response) -> response.objects
class FilterView extends Skel.View
events:
'keypress .field': 'filter'
filter: (event) =>
return unless event.which == 13
event.preventDefault()
@collection.fetch(reset: true, data: {title: @$('.field').val()})
jQuery ->
view = new Skel.View
el: $('#application')
template: t('application')
filter: FilterView
collection: new Items
view.render()
<div class="proposals">
{{#view opts.filter collection=view.collection className="filter"}}
<input type="search" class="field">
{{/view}}
{{#collection view.collection tagName="ul" className="items"}}
{{#models tagName="li" className="item" static=true}}
{{attrs.title}}
{{#collection model.variants tagName="ul" className="variants"}}
{{#models tagName="li" className="variant" static=true}}
{{attrs.title}}
{{/models}}
{{/collection}}
{{/models}}
{{/collection}}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment