A Pen by Jatinder Assi on CodePen.
Created
February 11, 2015 07:19
-
-
Save jatinder85/d63ea923c5eb5b115a1a to your computer and use it in GitHub Desktop.
WbdXQe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div id="movie-list"></div> | |
<div id="movie-detail"> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var json = [ | |
{ | |
"id": "603", | |
"name": "awesome movie" | |
}, | |
{ | |
"id": "604", | |
"name": "badass movie" | |
}, | |
{ | |
"id": "711", | |
"name": "foo movie" | |
}, | |
{ | |
"id": "811", | |
"name": "bar movie" | |
} | |
]; | |
var movie = function(id){ | |
var detailElem = document.getElementById('movie-detail'); | |
//Add IMDB ajax call here to get movie details | |
detailElem.innerHTML = 'This is movie detail for id:'+id; | |
} | |
var list = document.getElementById('movie-list'); | |
var dom = '<ul>'; | |
for(var i=0; i< json.length;i++){ | |
dom += '<li><a href="javascript:movie('+json[i].id+')">'+json[i].name+'</a></li>'; | |
} | |
dom += '</ul>'; | |
list.innerHTML = dom; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container{ | |
width:800px; | |
margin:0 auto; | |
} | |
#movie-list{ | |
float:left; | |
} | |
#movie-detail{ | |
float:right; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment