File: js/global.js
Line: 55

$('.toast').toast('show');

CommentFileSizeAuthor
#10 3034065-10.patch1.36 KBjeroent

Comments

carles.zapater created an issue. See original summary.

gillesbailleux’s picture

@carles.zapater: the Bootstrap 4 toast component is an alert message which JavaScript behavior is initialized in the official documentation with$('.toast').toast(option)
The .toast('show') event is called by$('#element').toast('show')

The Barrio theme is bundled with a twig file located at \templates\misc\status-messages--toasts.html.twig allowing you to customize your toasts.

hatuhay’s picture

Toasts is a new feature not present on older versions of Bootstrap 4.x.
This will only appear if you activate toasts, so either update your Bootstrap version o disable toasts.

hatuhay’s picture

Category: Bug report » Support request
Status: Active » Closed (works as designed)
jeroent’s picture

Status: Closed (works as designed) » Active

I disabled toasts in my theme settings, but I still get the same error.

gillesbailleux’s picture

@JeroenT: by "my theme settings", do you mean

  • through the UI at /admin/appearance/settings/bootstrap_barrio under the Components > Messages tab
  • through code in a file (which one please)
  • by commenting line 55 of js/global.js
jeroent’s picture

@gillesbailleux,

I mean through the UI at /admin/appearance/settings/bootstrap_barrio under the Components > Messages tab.

hatuhay’s picture

The real solution is to declare toast library that calls a toast.js, with the line of code inside and not on the global library.
This toast library should be called by the status-messages--toasts.html.twig template.
This way the function will only be called if toast message is required.
Collaborations welcome!!!!

hatuhay’s picture

Title: A line of code js has been incorporated with a function that does not exist » Uncaught TypeError: $(...).toast is not a function
jeroent’s picture

Status: Active » Needs review
StatusFileSize
new1.36 KB

Patch attached fixes the the problem for me. The toast.js files is only included when toast is configured in the theme settings.

Status: Needs review » Needs work

The last submitted patch, 10: 3034065-10.patch, failed testing. View results

jeroent’s picture

Status: Needs work » Needs review
jeroent’s picture

@PissedOff, some people spend their free time writing code and documentation. So it’s not really nice to act like this.

parijke’s picture

You're right Jeroen. I also get frustrated sometimes but then I think how much do I know and how much do I contribute?

I always sets me straight.

To mr. PO I would say: can you do better? Then please do so. The community will be thankfull

hatuhay’s picture

Status: Needs review » Fixed

  • hatuhay committed dd9bb43 on 8.x-4.x authored by JeroenT
    Issue #3034065 by JeroenT, gillesbailleux, carles.zapater: Uncaught...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

hgneng’s picture

Priority: Normal » Major

I still get error message in 8.x-4.22 in Drupal 8.6.14 minimal installation:

drupal.js?v=8.6.14:13 Uncaught TypeError: $(...).toast is not a function
at Object.attach (toast.js?v=8.6.14:12)
at drupal.js?v=8.6.14:25
at Array.forEach ()
at Object.Drupal.attachBehaviors (drupal.js?v=8.6.14:22)
at drupal.init.js?v=8.6.14:16
at HTMLDocument.t (ready.min.js?v=1.0.8:4)

In a clean Drupal minimal installation. It can reproduce the issue in theme "Bootstrap Barrio 8.x-4.22" while theme "Bootstrap Barrio Subtheme 8.x-4.22" works fine.

hgneng’s picture

I create a new ticket for issue of comment #26: https://www.drupal.org/project/bootstrap_barrio/issues/3051333