Skip to content

Instantly share code, notes, and snippets.

@avand
Created October 7, 2016 19:09
Show Gist options
  • Save avand/7d5f44fd6fb6ef1473e9522dd7c8e84e to your computer and use it in GitHub Desktop.
Save avand/7d5f44fd6fb6ef1473e9522dd7c8e84e to your computer and use it in GitHub Desktop.
var aladdin = document.querySelector(".aladdin");
var terminator = document.querySelector(".terminator");
aladdin.addEventListener("click", getMovie);
terminator.addEventListener("click", getMovie);
// ...and so on for each movie
// One event handler to rule them all...
function getMovie(event) {
var clickedMovie = event.target;
var imdbID = clickedMovie.id;
var url = "http://omdbapi.com/?i=" + id;
$.get("http://omdbapi.com/?i=tt0103639", displayResults);
}
function displayResults(results) {
// Update the table...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment