2

The basic example of snackbar for Material Design Components for Web doesn't work. It produces the error:

```
TypeError: snackbar.show is not a function
```

I have tried using jQuery to make sure the DOM loaded properly. I have tried changing back and forth the javascript initialisation methods, but none seems to work.

You can find the code here: https://jsbin.com/mejefeq/edit?html,console,output

I have read the docs over and overs again, but none of it mentioned anything about this. Since this MDC for Web is not at all popular, I have nowhere left to go for help.

timthekoder
  • 415
  • 5
  • 16
  • 1
    Have you tried running snackbar.open() ? That will display the DOM text content in the Snackbar body. If you want to change that use snackbar.labelText('New text'). More on that [here](https://github.com/material-components/material-components-web/tree/master/packages/mdc-snackbar) – Valentin Aug 23 '19 at 13:51

1 Answers1

2

Yeah that was a breaking change in the 0.43.0 update. The new way of showing the snackbar is by using

snackbar.open();

This however will just open the snackbar. If you want to change the text in the snackbar you can use:

snackbar.labelText = 'Your new text';

So together you can use them:

snackbar.labelText = 'Your new text';
snackbar.open();

You can check out more of the documentation here, with the current javascript properties and events here

Mr. Simmons
  • 448
  • 3
  • 14