1

It seems all the VueJS bootstrap components were built on version 1.x and I get nothing but errors (even with packages claiming to support 2.0) when trying to use any of the packages with Vue 2.x

Is it possible to trigger bootstraps dropdown creation on elements from the componentCreated life cycle?

e.g.

export default {
    componentCreated() {
        $(el).createDropdown();
    }
}

I've looked through the src of bootstraps dropdown but I cannot figure out how to call it on the element to initialize it as a dropdown.

Any help on this would be great thanks

1 Answer 1

1

I am very not sure about your bootstrap code but I dont see any componentCreated hook in vue lifecycle hooks. I think the hook you should be using is either created or mounted.

Following is vue lifecycle diagram:

enter image description here

In bootstrap 4 and in older versions as well, following is the JS code to create dropdown:

$('.dropdown-toggle').dropdown()
Sign up to request clarification or add additional context in comments.

2 Comments

I thought this only toggled the .hide class on the dropdown, and you're right, I was thinking of componentUpdated from directives
@Datsik yes you are right: $('.dropdown-toggle').dropdown() toggles dropdown, I am not sure of this code: $(el).createDropdown();.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.