HTML and CSS Reference
In-Depth Information
'<a class="back" href="/" data-controller="favorites" data-
action="list">my favorites</a>',
'</footer>'
].join('');
...
}
The next lines of code will check to see whether a movie is in the user's
favorites. If it is, it will change the state, data attributes, and text within the
favorite button.
...
app.view.movie = function(movie){
...
// Check to see whether the movie is in the user's favorites
if(movie.isFavorite()){
var _favoriteButton = _rootElement.querySelector('a.btn-favorite');
_favoriteButton.setAttribute('data-action', 'remove');
_favoriteButton.classList.remove('add');
_favoriteButton.classList.add('remove');
_favoriteButton.textContent = 'un-favorite';
}
...
}
Last but not least, you will need to loop through all of the actors that are in the
movie and append them to the cast list.
...
app.view.movie = function(movie){
...
for(var i = 0; i < movie.getActors().length; i++){
var actor = movie.getActor(i);
var element = document.createElement('li');
element.innerHTML = [
'<p>', actor.getName(), '<br />',
'<em>', actor.getRole(), '</em></p>'
].join('');
_rootElement.querySelector('#block-cast ul.list').appendChild(element);
}
...
}
 
Search WWH ::




Custom Search