rbiggs / chuki

An ES6 library using template literals to make components.
MIT License
0 stars 0 forks source link

Help with example #1

Closed Wikiki closed 6 years ago

Wikiki commented 6 years ago

Hi,

I'm trying to play with your code but I get an error on the following part:

// Define callbacks for events.
  logHello() {
    title.innerHTML = `Hello ${document.getElementById('hello').value}!`
  }

title is not defined.

Can you help me ?

rbiggs commented 6 years ago

Hmm... You need to have a reference to the title. I don't see one, neither will the browser, hence the error 'undefined'. You need to do something like:

// Define callbacks for events.
  logHello() {
     var title = document.querySelector('#title')
     title.innerHTML = `Hello ${document.getElementById('hello').value}!`
  }

That's assuming you have a title with an id of "title". Follow me?

rbiggs commented 6 years ago

I suggest you take a look at my other library, Composi. Chuki was a lot of experiments that eventually led to the development of Composi: https://composor.github.io

rbiggs commented 6 years ago

I've updated the example in the README so that it works. I also added some links to live Codepen examples.

Wikiki commented 6 years ago

Thanks a lot. I'll have a look to composor.