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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With