Closed lprc closed 4 years ago
Hi thanks for your question! You can still call it via iqwerty.toast.toast()
-- see the Playground for examples! The breaking change with ebd3c88 was Toast()
to toast()
lowercase. You can probably set iqwerty.toast.Toast = iqwerty.toast.toast
if you don't want to change all references. Please let me know if that worked!
Hmm maybe I'm doing something wrong. Here are some small test files I used:
index.html:
<head>
<script type="module" src="toast.js"></script>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<input type="button" value="show toast" onclick="showToast()" />
</body>
test.js:
function showToast() {
iqwerty.toast.toast("test");
}
toast.js
is in the same folder as the two files above. Now when I click on the button I get an error message on console saying
Uncaught ReferenceError: iqwerty is not defined
showToast http://127.0.0.1:5500/test.js:2
onclick http://127.0.0.1:5500/:1
Hi, please use toast.min.js instead. I got confused because in comment 1 the script tag imported the minified one already :)
Oh yeah that works indeed. Sorry, that mistake was on me. Anyways I think the minified version should not behave differently, does it?
In addition, which minifier did you use? I added support for a dismissable toast using a x-button on the right hand side and then stumbled on this issue.
Thanks for your responses so far! :)
Hi--sorry for the late response. The minified one shouldn't behave differently, but it is bundled using parcel. I have this weird custom build that I haven't open-sourced yet. As for dismissable toast, do you think the snackbar would work for you?
Looks great, thanks!
Hi, now as the code has been converted to conform to the module syntax using
export
, how can I include it in my code? E.g. before I'd just use<script type="text/javascript" src="lib/toast.min.js"></script>
in myindex.html
and was then able to useiqwerty.toast.Toast("blabla")
. Now I think I do have to use animport
statement, right? But that just seems to work from inside a module. Is there a possibility to import it into a global variableiqwerty.toast
like before?This information would be nice in the Readme, too.