Populate the General Recordings List. For this TODO, you must assemble a new <section>
and <ul>
for Billy's general recordings data. Unlike TODO 4, there is not a section
or unordered list
in the DOM
for the recordings, so you must use jQuery
to create those elements
, too.
Create a recordings
<section id="section-recordings">
and add it below the section for top rated recordings in thesidebar
. How can you achieve this withjQuery
?Create a
<ul id="list-recordings" class="list-recordings">
,style
it, and add it to the<section id="section-recordings">
.Add a styled
<li class="recording">
for every recording in the recordings Array. Whatlodash
methods can help you here?Add a separate
<div>
for thetitle
,artist
,release
, andyear
of each recording. Give them aclass
based on their key in the object.Add
CSS
styling rules to thecss/site.css
file to style the list items. Can these style rules apply to list items in both the top rated and recordings lists? How can you achieve this withCSS
selectors/rules
andjQuery
?
The resulting HTML
should look something like this:
<section id="section-recordings">
<ul id="list-recordings" class="list-recordings">
<li class="recording">
<div class="title">Title: Eastern Rebellion</div>
<div class="artist">Artist: Cedar Walton</div>
<div class="release">Release: Timeless</div>
<div class="year">Year: 1976</div>
</li>
<!-- more list items here -->
</ul>
</section>
However, my HTML
file looks like this:
<div id="sidebar" class="sidebar">
<div id="image-container-billy" class="image-container">
<img
id="image-billy"
src="images/billy/billy-0.jpg"
i="0"
width="25%"
class="image"
/>
</div>
<section id="section-top-rated" class="recordings">
<header id="header-top-rated" class="header-recordings">
Top Rated
</header>
<ul id="list-top-rated" class="list-recordings"></ul>
<li>Voice in the Night</li>
<li>The Shape of Jazz to Come</li>
<li>Like Sonny</li>
<li>Go</li>
<li>The Water Is Wide</li>
<section id="section-recordings">
<ul id="list-recordings" class="list-recordings"></ul>
<div class="title">Eastern Rebellion</div>
<div class="artist">Cedar Walton</div>
<div class="release">Timeless</div>
<div class="year">1976</div>
<div class="title">Soul Food</div>
<div class="artist">Bobby Timmons</div>
<div class="release">Prestige</div>
<div class="year">1966</div>
<div class="title">A Swingin' Affair</div>
<div class="artist">Dexter Gordon</div>
<div class="release">Blue Note</div>
<div class="year">1962</div>
<div class="title">Rejoice</div>
<div class="artist">Pharoah Sanders</div>
<div class="release">Theresa</div>
<div class="year">1981</div>
</section>
</section>
</div>
This is where my code
in the JS
file begins:
const onReady = data => {
// YOUR CODE BELOW HERE //
$('#section-bio').css('color', 'brown');
$('#section-quotes').css('color', 'blue');
/* eslint-enable */
// TO DO 4 ////
const topRated = data.discography.topRated;
let newSection = document.createElement('section');
topRated.forEach(recording => {
$('#section-top-rated').append(`<li>${recording.title}</li>`);
//let topR = $('#section-top-rated').append(`<li>${recording.title}</li>` );
});
const recordings = data.discography.recordings;
$(`<section id="section-recordings"></section>`).appendTo(
'#section-top-rated'
);
//$(`<ul id="list-recordings" class="list-recordings"></ul>`).appendTo('#section-recordings')
//$(`<li class="recording></li>`).appendTo('#list-recordings').appendTo('#list-recordings')
$('#list-recordings').append(`<li class="recording></li>`);
$(`#section-recordings`).append(
`<ul id="list-recordings" class="list-recordings"></ul>`
);
//$('#list-recordings').append(`<li class="recording></li>`)
recordings.forEach(element => {
$(`<li class="recording"></li>`);
$('#section-recordings').append(
`<div class="title">${element.title}</div>`
);
$('#section-recordings').append(
`<div class="artist">${element.artist}</div>`
);
$('#section-recordings').append(
`<div class="release">${element.release}</div>`
);
$('#section-recordings').append(
`<div class="year">${element.year}</div>`
);
});
const uL = document.createElement(
'ul id="list-recordings" class="list-recordings"'
);
uL.appendTo(`#section-recordings`);
//let newSection = document.createElement('section');
//$(<section id="section-recordings"></section>)
// const recordings = data.discography.recordings;
//recordings.forEach(songs){
// }
// YOUR CODE ABOVE HERE //
};
Everything I tried has been commented out with the //
markers. I have been stuck on this problem all day. I don't know why but my <li></li>
lists aren't showing up and I feel like that makes this problem much more difficult to solve due to their absence. I can't see where it's at so I don't know how to move it around.
Just a side note, the actual data.discography.recordings
references an array of objects
.
Any level of assistance would help, even just words of encouragement. Cheers to anyone who attempts to help me with this issue. If I could at least figure out why I can't find <li class="recordings"></li>
then that would be a huge step.
$(`<li class="recording"></li>`)
(i.e. the first line in therecordings.forEach((element) => {
loop) does nothing at all - at least, nothing useful - it creates anli
... then does nothing with it