Restored packages and fixed issues with aurelia-validation
Add to nav-bar.html the sample HTML from Bootstrap 3.3.7 Navbar for dropdown (just the
code).
Run the app and it works as should, the dropdown is functional
Add import ‘bootstrap’; to welcome.ts
Run the app and not it does not work, the dropdown is now broken and the submenu does not show
My ultimate goal was to get bootstrap tooltip to work. The steps above is how I was able to reproduce an error I’m having with my project. I want to simplify it and remove doubt about something within my project.
My question, how to get dropdown to work with import ‘bootstrap’; ? If I can’t get import ‘bootstrap’; to work in code then I can’t get tooltip to work.
I noticed using Chrome there is an additional Event Listener when import ‘bootstrap’; is used. It looks to be jQuery. If I remove the Event Listener it works. But I can’t have $(‘[data-toggle=“tooltip”]’).tooltip() without jQuery and Bootstrap.
Which points to this.
if ( !( eventHandle = elemData.handle ) ) {
eventHandle = elemData.handle = function( e ) {
// Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded
return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
jQuery.event.dispatch.apply( elem, arguments ) : undefined;
};
}
Don’t know why or what, but this was a try anything and everything until it sticks.
I read a blog post, unrelated other than Webpack and Bootstrap, In the blog article the individual components of Bootstrap was loaded. So, instead of loading Bootstrap I loaded collapse and tooltip. Also had to load $ from jQuery separately. My repository is updated to reflect these changes.
Instead of
import ‘bootstrap’
I changed to
import $ from 'jquery"
import ‘bootstrap/js/collapse’
import ‘bootstrap/js/tooltip’
I was not happy with just leaving it alone without knowing. More trial and error. So, I tried to load all of the bootstrap JavaScript individually. Then commented them out one by one until I found the offending one. Ironically when I picked import ‘bootstrap/js/collapse’ I did not see the more logical option, import ‘bootstrap/js/dropdown’, which was a good thing, otherwise I would still be stuck. Why would I still be stuck you ask, when I went and commented out the individual JavaScript the offending JavaScript was… you guessed it import ‘bootstrap/js/dropdown’.
There is data-toggle=“dropdown” in the HTML which indicates it would need import ‘bootstrap/js/dropdown’ based on Bootstrap documentation. Instead that breaks it. When using import ‘bootstrap/js/collapse’; it works, which in theory it should not.
Found out it does not break, it just does not, how to say this, auto wire up the event. If you add the code below it will work with import ‘bootstrap/js/dropdown’. I just don’t know what the magic is that wires this up with HTML only and having no import ‘bootstrap’ in the JavaScript. How does it work with HTML only? What identifies the HTML as having data-toggle=“dropdown” and then knows to load import ‘bootstrap/js/dropdown’ and then to call ** $(‘.dropdown-toggle’).dropdown()**. Furthermore why does adding Bootstrap in JavaScript kill the magic leaving one confused.
it is the bundled version, in which all libraries are included
I used in one of my repositories both tooltip and dropdown of bootstrap v4-beta.3 and it just works fine in all browsers. It’s loader is fusebox and using another skeleton though.