简体   繁体   中英

Bootstrap tagsInput typeahead : How to exclude some input fields?

I've a simple html page with bootstrap-tagsinput and I have 2 forms. I would like to activate the typeahead functionality for some input fields but not all.

As I could see, when an html object is an input field, for example :

<input size="5" type="text" placeholder="hotel">

it is automatically 'overwritten' like this :

<div class="bootstrap-tagsinput">
    <input size="5" type="text" placeholder="hotel">
</div> 

and I get the typeahead functionality through my script :

    $('input').tagsinput({
            typeahead: {
            source: ['Paris','Marseille',....],
            freeInput: true
            }
    });

However, I would like to exclude some fields from this typeahead and tags input behavior. I've tried some tweaks on the css and js files but it does not work. Is there any simple way to exclude such fields ? Thanks.

Add a class or id to the inputs you want to include typeahead:

<input size="5" class="typeahead" type="text" placeholder="hotel">

And select that when you initialize typeahead:

$('input.typeahead').tagsinput({
               ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM