Here is an example of a button whose loading and disabled states are controlled by the parent component.
When you click the button, a loading animation is displayed.
At the same time, the button goes into the disabled state.
After the work is done (i.e. a server response received), the button returns to its initial state.
The animation in this example was made with pure CSS animation.
The snippet is using the most current version of Mithril.js framework.
It is aimed at beginners and shows some basic recipes.
Besides Mithril.js' hyperscript function m() we can see different Mithril.js API methods like m.mount or m.redraw.
In this example we can also see the usecase of Vnodes (virtual DOM nodes) which is a JavaScript data structure that describes a DOM tree.
The example was contributed by tbreuss and last modified on 29 January 2022.
Click here to see more examples contributed by the author.
If anyone has some improvements, that should be addressed, let me know by opening an issue.
Or simply fork the repository on GitHub, push your commits and send a pull request.
For starting your work, you can click the edit link below. Thanks for contributing.