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

Docs: live examples of alerts and toasts #31330

Closed
patrickhlauke opened this issue Jul 20, 2020 · 5 comments · Fixed by #33866
Closed

Docs: live examples of alerts and toasts #31330

patrickhlauke opened this issue Jul 20, 2020 · 5 comments · Fixed by #33866

Comments

@patrickhlauke
Copy link
Member

Not sure how easy/difficult it would be, since they require initialisation, but...would be nice to have actual working examples for https://v5.getbootstrap.com/docs/5.0/components/alerts/ and https://v5.getbootstrap.com/docs/5.0/components/toasts/

@techboyg5
Copy link

techboyg5 commented Jul 22, 2020

They already exist, you just linked to them :)

@patrickhlauke
Copy link
Member Author

they're already present and visible on the page when it loads. need live examples where you'd trigger something and THEN they show up. smartypants.

@StarTrooper08
Copy link

@patrickhlauke Ya great idea that would be nice and beginner will easily understand the use of the bootstrap component .
But do the example should be in gif image form or exact coded form ?

@XhmikosR
Copy link
Member

XhmikosR commented Jan 18, 2021

Not sure how to proceed with the Alert live example. The moment it's closed, the element is removed from the DOM.

I think we need to recreate the element through JS so that we have a button which says Show Alert and manually hide/show it when the close button is clicked.

@planetoftheweb
Copy link
Contributor

planetoftheweb commented Apr 20, 2021

I agree. I'm working on the course for Bootstrap Essential Traninig and found this code to be confusing for a user:

var toastElList = [].slice.call(document.querySelectorAll('.toast'))
var toastList = toastElList.map(function (toastEl) {
  return new bootstrap.Toast(toastEl, option)
})

[].slice.call is cool, but not the clearest to understand. Plus, it doesn't show you how to implement a button click.

This code initializes the toasts, but doesn't show you how to call a toast from a button.

Here's something I did.

document.querySelector("#basicToastBtn").onclick = function() {
 new bootstrap.Toast(document.querySelector('#basicToast')).show();
}

With a corresponding CodePen to illustrate:

https://codepen.io/planetoftheweb/pen/vYgVBGb?editors=1010

I think you need some examples like that instead of just the initialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants