Typeahead plugin and Bootstrap Tags input plugin Meteor not working

后端 未结 5 1244
太阳男子
太阳男子 2021-02-05 19:15

We\'ve installed \'bootstrap-tagsinput.js\' and the \'typeahead\' plugin for doing a tyepahead drop down for tags for an input field in one of our forms. The hardcoded tags work

相关标签:
5条回答
  • 2021-02-05 19:36

    I am not sure if it is too late to answer this question.. But I had the same problem and I used typeahead for bootstrap 3 with the bellow code snippet. Hope this will help someone...

    <input id="my-tags" type="text" placeholder="Add tags" data-provide="typeahead"/>
    
     <script type="text/javascript">
               var colors = ["red", "blue", "green", "yellow", "brown", "black"];
               var elt = $('#my-tags');
               elt.typeahead();
               $('#my-tags').tagsinput({
                    typeahead: {
                         source: colors
                    }
               });
      </script>
    
    0 讨论(0)
  • 2021-02-05 19:36

    Took me a few hours but here's what worked for me: besides using bootstrap3-typeahead (and not typehead.js) I also had do use an older version of it v3.1.1.

    0 讨论(0)
  • 2021-02-05 19:43

    I think the source attribute should be a function.

    Template.form.rendered = function() {
        // Initialise tags input
        $('.tags').tagsinput({
            typeahead: {
                source: function(query) {
                    return ['Amsterdam', 'Washington', 'Sydney', 'Beijing', 'Cairo'];
                }
            }
        });
    };
    
    0 讨论(0)
  • 2021-02-05 19:44

    Same problem here. Resolved dropping the original typeahead.js (that is not compatible with Bootstrap 3) and using bootstrap3-typeahead.js (https://github.com/bassjobsen/Bootstrap-3-Typeahead).

    Moreover, you don't need to add (actually on some occasions you MUST remove it in order to work)

    data-role="tags input"
    

    when you specify

    $('#my_field').tagsinput({ typeahead: ...
    
    0 讨论(0)
  • 2021-02-05 19:52

    I'd like to clarify some of the other answers since they're not saying it clearly enough.

    Currently, the highest voted package for typeahead on Atmosphere is by sergeyt:typeahead. Apparently, there's some issues when using this package.

    After fiddling with it for about an hour, I searched for an alternative. After installing mrt:bootstrap3-typeahead - everything worked as expected.

    So my recommendation is to try that package if you're having problems.

    0 讨论(0)
提交回复
热议问题