Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Snackbar show method should not require message parameter #2628

Closed
@memestageceo

Description

@memestageceo

I am trying to use the snackbar that ships with MDC for web with connect-flash of express. If i simply add the snackbar element like this, it dosn't seem to work

block messages
      if locals.flashes
        - const categories = Object.keys(locals.flashes)
        each category in categories
          each message in flashes[category]
            #mdc-js-snackbar
              .mdc-snackbar(aria-live="assertive", aria-atomic="true" aria-hidden="true")
                .mdc-snackbar__text!= message
                .mdc-snackbar__action-wrapper
                  button.mdc-snackbar__action-button Ok

Also, i've added the JS

import * as mdc from "material-components-web";

function initSnackbars() {
  [].forEach.call(document.querySelectorAll('.mdc-snackbar'), bar => {
    snackbar.MDCSnackbar.attachTo(bar);
    const data = { timeout: 2750 };
    bar.show(data)
  });
}

export default initSnackbars;

The main problem seems to be the message attribute that has to be provided via data obj to snackbar.show(data).
Please, can you give me an example of how I can use mdc-snackbar with connect-flash.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions