Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabled inputs in bootstrap. How to apply it to a different TAG?

By using disabled attribute on an input is possible to prevent user input and trigger a slightly different look.
Here is the demo http://jsfiddle.net/D2RLR/3023/

Let's suppose I want to apply the same style to a different TAG like a table.
In fact, I am using handsontable to generate an Excel-like data grid editor.
How can I apply disabled attribute in the following context (TAG like a table)?

Here is the demo using handsontable and bootstrap http://jsfiddle.net/D2RLR/3025/

like image 659
Lorraine Bernard Avatar asked Oct 31 '12 00:10

Lorraine Bernard


People also ask

Is disable an attribute of input tag?

The disabled attribute is a boolean attribute. When present, it specifies that the <input> element should be disabled. A disabled input element is unusable and un-clickable.

How do I make labels disabled in HTML?

First step: swap the HTML elements order so that the <label> appears after the <input> . This will allow the styling rules to work as desired. Then for the fun bit: use CSS to position the labels for text inputs on the left hand side! input[type=radio]:disabled+label works like a sharm!


2 Answers

You can't apply Bootstrap's existing input[disabled] styling, but you can add new CSS that mimics the styles exactly.

For example:

#exampleGrid td {
    cursor: not-allowed;
    background-color: #EEE;
    color: #9E9999;
}

Obviously this doesn't include your readonly logic, and looks a little weird with your fiddle (because the column and row headers are the same color), but that's the gist of it.

like image 137
Sara Avatar answered Sep 23 '22 10:09

Sara


Check here:

http://handsontable.com/demo/conditional.html

There is .readOnly cell property - use it!

HTML inputs also have readonly property, not only disabled property, an there are some considerable differences between their behaviour.

like image 37
Reflective Avatar answered Sep 19 '22 10:09

Reflective