Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap + jade checkbox

Folks, Im quite new to jade and bootstrap. Creating a simple form, which has dropdowns and checkboxes.

Right now my code looks as follows:

form(role="search",action='/uri/blah' method='post').navbar-form.navbar-left
    .form-group 
        input(type="name", name="bae", placeholder="bae", required).form-control
        select(id="type",name="type").form-control
            option(value="foo") foo
            option(value="bar") bar
            option(value="baz") baz
        input(type="text", name="X", placeholder="X", required).form-control
        input(type="checkbox", name="checkboxname", text="asdf").form-control
    p           
    button(type="submit").btn.btn-default Submit

Questions: 1.) Checkbox name, whats the proper syntax to label it? 2.) How to make the form more dynamic? Ie, if a checkbox is clicked or a dropdown is selected, another would appear?

Thanks

like image 560
Cmag Avatar asked Dec 31 '13 01:12

Cmag


1 Answers

Unfortunately, in order to make it dynamic, you can't do it in Jade. You would have to rely on jQuery or other front-end libraries to handle that.

I label my Checkbox like this:

label(for="checkbox")
  input(type="checkbox", name="checkboxname", value="value").form-control
  | Checkbox Label Goes Here

If I want to set default values from the server:

label(for="checkbox")
  input(type="checkbox", name="checkboxname", value="value" checked=data.checked?"checked":undefined).form-control
  | Checkbox Label Goes Here
like image 79
tpae Avatar answered Nov 12 '22 02:11

tpae