Skip to content
pelonpelon edited this page Jul 21, 2015 · 35 revisions

Common questions found on Gitter, the Google Group, and StackExchange
Contributors: Please add links to gists instead of lengthy code examples


  1. Where can I find help learning Mithril?
  1. How can I add animation to my Mithril app?
  1. How do I fix this error: "Please ensure the DOM element exists before rendering a template into it."
  • Try putting the script tag for the offending javascript as the last thing inside the body tag.
  1. What is a top-most component?
  1. Why doesn't my component render?
  • The component view function must return a virtual element, not an array of elements:
    return m("div")
    return [m("div")]
  • Only a top-most component may return an array:
    App.view = function(){ return [ m("div"), m("div") ] }
  1. How do I (re)initialize all controllers in my app?
  • m.route( m.route() )
  1. How do I unmount/unload a component?
  1. How do I make an m.route change without scrolling the page
  • call m.route in a setTimeout with duration 0 (This is a quirk of v0.2.0 and may not survive updates)
Clone this wiki locally