const dataElement = $('#messages-container');
const data = dataElement.data('messages');

// -----

Object.keys(data).forEach((key) => {
  Materialize.toast(data[key], 5000);
});

const dataElement = $('#messages-container');
const data = dataElement.data('messages');

// -----

if(data) {
  Object.keys(data).forEach((key) => {
    Materialize.toast(data[key], 5000);
  });
}

Fix bug if script fired in styleguide view
Fix bug if script fired in styleguide view
