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

Dropdowns not shown on Bootstrap 4 #364

Open
wtlyu opened this issue Dec 15, 2018 · 2 comments
Open

Dropdowns not shown on Bootstrap 4 #364

wtlyu opened this issue Dec 15, 2018 · 2 comments

Comments

@wtlyu
Copy link

wtlyu commented Dec 15, 2018

I was curious if my usage is wrong.

Once a dropdown is about to show, it usually looks like <ul class="typeahead dropdown-menu" role="listbox">. However, these kind of dropdown-menu won't show unless I add .show by hand. like this:

<ul class="typeahead dropdown-menu show" role="listbox">

Any suggestions about this? I'm using Material Design for Bootstrap 4.1.1 which is based on Bootstrap 4 ( it won't change any Bootstrap behavior I think )

@codedge
Copy link

codedge commented Mar 5, 2019

I cannot confirm this. For me it does not work too with Bootstrap 4.3.1.

There is most likely a problem with your datasource. The plugin expects to have a source like

[
  {"id": 1, "name": "name1"},
  {"id": 2, "name": "name2"},
]

So id and name should be in the source. If you have other identifiers use the displayText method to change it.

What works for me is:

<input type="text" class="form-control cat-typeahead typeahead"
                                   name="category" id="category" data-provide="typeahead" autocomplete="off">
$('.cat-typeahead').typeahead({
        items: 10,
        displayText: function (item) {
            return item.cat_title;
        },
        source: function(query, process) {
            let url = "{{ route('api.story-categories.autocomplete', ['query' => ':query']) }}";
            url = url.replace(':query', query);
            return $.get(url, function (data) {
                process(data);
            });
        }
    });

Works with BS 4.3.1 and latest Jquery 3.11.1.

@bigalnz
Copy link

bigalnz commented May 13, 2019

I can't get it to go with BS4. Everything seems ok, but no dropdown appears.

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

3 participants