small medium large xlarge

Generic-user-small
05 Jan 2018, 03:27
Ryan W (2 posts)

Interesting issue, I compiled the following Elm file:

module Picshare exposing (main)

import Html exposing (Html, div, text)

main : Html msg
main =
  div [] [text "Picshare"]

But in attempting to view it in the browsers (using the suggested html file and associated modifications on page 20 of the book, I get the following error being thrown by the Javascript engine (in Chrome):

Uncaught TypeError: Cannot read property 'lastChild' of null
    at Object.embed (picshare.js:7258)
    at index.html:20

Anyone ever run into this in an Elm application?

Generic-user-small
05 Jan 2018, 03:38
Ryan W (2 posts)

My mistake, I figured it out. I had put the script tag in the page head element instead of the body:

  <script src="picshare.js"></script>
  <script>
    Elm.Picshare.embed(document.getElementById('main'));
  </script>
Bio-2017-4_pragsmall
10 Jan 2018, 20:28
Jeremy Fairbank (4 posts)

Thanks for the message, Ryan. I’m glad you figured it out. Happy Elm coding!

You must be logged in to comment