-1

I am using the material design lite and I would like to open Snackbar on page load, i tried few solutions which i found but unfortunately without success. Do you have any working example?

Ages
  • 99
  • 1
  • 1
  • 9

1 Answers1

6

Sorry, I already solve this. Here is the code example:

<div id="demo-toast-example" class="mdl-js-snackbar mdl-snackbar">
  <div class="mdl-snackbar__text"></div>
  <button class="mdl-snackbar__action" type="button"></button>
</div>

<script>
r(function(){
    var snackbarContainer = document.querySelector('#demo-toast-example');
    var data = { message: 'Example Message.'};
    snackbarContainer.MaterialSnackbar.showSnackbar(data);
});
function r(f){ /in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}
</script>
Ages
  • 99
  • 1
  • 1
  • 9