Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Object-Oriented JavaScript (2015) Constructor Functions and Prototypes Making the UI Work

liktid
liktid
6,387 Points

Why do we need to call renderInElement in the onclick functions?

I whonder why we need to call this method on the playButton, stopButton and nextButton. This method creates a list of the songs attached to the #playlist-element. I simply cant follow, why this changes the current state for the songs by clicking on of the buttons.

Thank you

2 Answers

Anthony Hernandez
Anthony Hernandez
7,365 Points

renderInElement updates the html view. the states of our object instances within app.js would be updated (i.e. a song would be stopped or played, and/or the track number would change), but the view wouldn't reflect that, without this method call. it's worth noting that this isn't the most efficient means of doing so, but it works for the purpose of this video series.

i hope this helps!

liktid
liktid
6,387 Points

It looks still a bit wierd for me but thank you for your answer.