Skip to content

Instantly share code, notes, and snippets.

@justinbmeyer
Created June 22, 2012 16:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinbmeyer/2973930 to your computer and use it in GitHub Desktop.
Save justinbmeyer/2973930 to your computer and use it in GitHub Desktop.
BackboneUI done with CanJS

Button

<button><%= coffee.attr('roaster') %></button>

Checkbox

<input type='checkbox'
       <%= coffee.attr('acidic') ? 'checked' : '' %> /><%= coffee.attr('roaster') %>

Link

<a href="javascript://"><%= coffee.attr('roaster') %></a>

Textarea

<textarea><%= coffee.attr('region.name') %></textarea>

Text Field

<input type='text' value="<%= coffee.attr('roaster') %>"/> 

Pull down

Template:

<select class='pulldown'>
<% alternatives.each(function(item, index){ %>
  <option value="<%= index %>" <%= model.attr(content) == item ? "selected" : "">
    <%= item.attr(this.altLabelContent) %>
  </option>
<% }) %>
</select>
Pulldown = can.Control({
  init : function(){
    this.element.html( can.view('pulldowntemplate',this.options ) );
  },
  "change" : function(){
    this.options.model.attr(this.options.content, this.options.alternatives[this.element.val()] );
  }
})

List View

<% regions.each(function( region ) { %>
  <li><%== can.view.render("SUBTEMPLATE", region ) %></li>
<% }) %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment