Skip to content

Instantly share code, notes, and snippets.

@jatinder85
Created February 11, 2015 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jatinder85/d63ea923c5eb5b115a1a to your computer and use it in GitHub Desktop.
Save jatinder85/d63ea923c5eb5b115a1a to your computer and use it in GitHub Desktop.
WbdXQe
<div class="container">
<div id="movie-list"></div>
<div id="movie-detail">
</div>
</div>
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;
.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