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?
Asked
Active
Viewed 865 times
-1
-
add here some code example which you tried so far,It will be helpful – Rahal Kanishka Aug 10 '16 at 08:57
-
Show us the code what you tried so far. – UDID Aug 10 '16 at 08:58
1 Answers
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