Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1278 Lượt xem

I am trying to show my Bootstrap dropdown menu on t-on-keyup. 

When i try to call new bootstrap.Dropdown(element) is says that it's undefined.

If I'm correct, bootstrap is already inside the odoo system. So I don't have any imports for bootstrap in my application.

This is the function I am trying to call:

showDropdown = (dropdownElement) => {
    if (dropdownElement) {
​const dropdown = new bootstrap.Dropdown(dropdownElement);
​dropdown.show();
    }
}

Do I still need to import bootstrap individually? Or am I doing something else wrong?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

For anyone else wondering, I think it depends on the bootstrap version being used. 

For me it worked with:

$("#element_id").modal("show") # or .modal("hide")

More here: getbootstrap.com/docs/4.0/components/modal/

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

I found out that you can access DOM elements via jQuery like this "$(element)".

So I made it work with $('#dropdownElement').show()

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 3 25
2855
1
thg 2 25
1394
0
thg 11 24
974
2
thg 10 24
1606
1
thg 10 24
11744