Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a checkbox field and render a checkbox.

  • Loading branch information...
commit 511c181775b69779abbac4114436e1428f7251cf 1 parent 8309d82
Chris Nelson authored
14 example/spec/javascripts/views/check_box_view_spec.coffee
View
@@ -0,0 +1,14 @@
+describe "check box view", ->
+ beforeEach ->
+ setFixtures "<div id='check_box_view'></div>"
+ @model = new Example.Models.Thing(awesome: true)
+ @checkBoxFieldView = new Backtastic.Views.CheckBoxView
+ model: @model
+ field: "awesome"
+ label: "Awesome"
+ el: $("#check_box_view")
+ parentView: new Example.Views.FormView
+ @checkBoxFieldView.render()
+
+ it "renders a check box input", ->
+ expect(@checkBoxFieldView.$("input[type=checkbox]")).toExist()
2  lib/assets/javascripts/templates/check_box_template.jst.hamlc
View
@@ -0,0 +1,2 @@
+%label{for: @field}= @label
+%input{type: "checkbox", name: @field, value: @model.get(@field)}
5 lib/assets/javascripts/views/check_box_view.coffee
View
@@ -0,0 +1,5 @@
+#= require ./form_field_view
+class Backtastic.Views.CheckBoxView extends Backtastic.Views.FormFieldView
+
+ template: JST["templates/check_box_template"]
+
Please sign in to comment.
Something went wrong with that request. Please try again.