Read only or disable jquery shortcuts

I use this http://xoxco.com/projects/code/tagsinput/ to enter my tags.

But does anyone know how to set tag divs to read-only mode or disable it?

+5
source share
4 answers

try the following:

$('#tags').tagsInput({
        'interactive':false
        });

if you want to disable the removal of the "X". use it below.

$('.tagsinput').find('a').remove();
+11
source

This should work:

$('.tagsinput input').attr('disabled', 'disabled');

To make it editable, you can do:

$('.tagsinput input').removeAttr('disabled');
+3
source

:

var tagsinput = $('#id-tagsinput').next();
tagsinput.removeClass('bootstrap-tagsinput');
tagsinput.find("input").remove();
tagsinput.css("padding-bottom", "10px");

()

var tagsinput = $('#id-tagsinput').next();
$('[data-role="remove"]').remove();
tagsinput.find("input").remove();
tagsinput.css("padding-bottom", "10px");

+1

. , .

: CSS.

CSS JS DOM .

.bootstrap-tagsinput.disabled {
    border: none;
    box-shadow: none;
}
.bootstrap-tagsinput.disabled input {
    display: none;
}
.bootstrap-tagsinput.disabled .badge span[data-role="remove"]{
    display: none;
}

, :

.bootstrap-tagsinput.disabled .badge {
    background-color: #ccc;
    border: 1px solid #ababab;
}

Then, when you want to enable / disable, just add or remove disabledthe CSS class from the root of this element (class with CSS class bootstrap-tagsinput).

0
source

All Articles