Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readonly input attribute or similar #112

Closed
santimacia opened this issue Mar 25, 2014 · 13 comments
Closed

readonly input attribute or similar #112

santimacia opened this issue Mar 25, 2014 · 13 comments

Comments

@santimacia
Copy link

It's possible to use the readonly attribute? I tried to put it but when it's rendered the attribute disappears.

@danielsvane
Copy link
Contributor

Isn't it possible to simply not initialize the input as a tagsinput?

@danielsvane
Copy link
Contributor

Silly of me, of course it could be a use case when you want to display the tags but not edit them.

This was referenced Jul 11, 2014
@fouimette
Copy link

Is there read-only support? I would like to be able to display the tags (categorized and all) in a read only scenario. Only the originator will have the ability to edit/change the tags. Also, it would be nice to display the tags, in a read-only state, outside of input fields. Such as a label.

@KrishnaPG
Copy link

The disabled state PR(https://github.com/bootstrap-tagsinput/bootstrap-tagsinput/issues/166) is good one to start with, but still the UI is not reflecting the "disabled" state. For example, below is the screenshot of one such control in disable state (but looks like it is functional until user clicks it and it does not respond, driving them crazy). Perhaps removing the "x" marks in the individual items and removing the "all encompassing white box in the background" to show only the items could be useful.

image

Something like below (mockup, not real ) should do:
image

@ktohme
Copy link

ktohme commented Nov 10, 2015

I'm also looking for a possibility for really disabling the input field like KrishnaPG has advised

Edit: Here is some dirty hack you could use

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

@drmalus
Copy link

drmalus commented Dec 3, 2015

Hi all!

I had the same problem.
My dirty hack is:

.bootstrap-tagsinput .tag [data-role="remove"] { display: none; }
.bootstrap-tagsinput input { display: none; }

@Disane87
Copy link

Disane87 commented Apr 1, 2016

I really would love the solution @KrishnaPG described.

@kimyu92
Copy link

kimyu92 commented Jun 8, 2016

@drmalus not a bad idea

using similar idea, to prevent input but allow user to remove

.bootstrap-tagsinput {
   border: none;
   box-shadow: none;
}
.bootstrap-tagsinput input {
   display: none;
}

@drmalus
Copy link

drmalus commented Jun 8, 2016

@kimyu92 that's right! Thanks for the correction!

@querubinRamonchito
Copy link

You can do this:

$('#tagsInputId').attr('disabled','disabled');

if(isDisabledVar !== true){
$('#tagsInputId').removeAttr('disabled');
}

By doing the above code, you're adding disabled attribute to the textbox itself. This is somehow the answer to @fouimette 's question:

Is there read-only support? I would like to be able to display the tags (categorized and all) in a read only scenario. Only the originator will have the ability to edit/change the tags

Depending on what javascript library you're using, this will do the trick. Since the above scenario requires that only the originator will have the ability to edit/change the tags, it will be fine to add this condition as a replacement for the if(variable)...

I hope it helps.

@kompiuter
Copy link

An additional method to prevent user input while allowing the user to remove:

$(document).ready(function() {
    $(".bootstrap-tagsinput > input").prop("readonly", true);
})

@expressiveco
Copy link

Following could be used to disable editing for specific input;

$('#tagsInputId').tagsinput('input').prop("readonly", true);

An additional method to prevent user input while allowing the user to remove:

$(document).ready(function() {
    $(".bootstrap-tagsinput > input").prop("readonly", true);
})

@Ken0420
Copy link

Ken0420 commented Oct 17, 2019

try this one,
$( "#tagsInputId" ).prop( "disabled", true );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests