Created
October 25, 2013 21:10
-
-
Save terrancebryant/7161891 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-latest.js"></script> | |
<meta name="description" content="Refactor To objects" /> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<button class="clickster">Click Bitch</button> | |
</body> | |
</html> |
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 tour = { | |
init: function() { | |
$("#tour").on("click", "button", function() { | |
$.ajax('/photos.html', { | |
data: {location: $("#tour").data('location')}, | |
success: function(response) { | |
$('.photos').html(response).fadeIn(); | |
}, | |
error: function() { | |
$('.photos').html('<li>There was a problem fetching the latest photos. Please try again.</li>'); | |
}, | |
timeout: 3000, | |
beforeSend: function() { | |
$('#tour').addClass('is-fetching'); | |
}, | |
complete: function() { | |
$('#tour').removeClass('is-fetching'); | |
} | |
}); | |
}); | |
} | |
}; | |
var tour = { | |
init: function() { | |
$("#tour").on("click", "button", this.fetchPhotos); | |
}, | |
fetchPhotos: function() { | |
$.ajax('/photos.html', { | |
data: {location: $("#tour").data('location')}, | |
success: function(response) { | |
$('.photos').html(response).fadeIn(); | |
}, | |
error: function() { | |
$('.photos').html('<li>There was a problem fetching the latest photos. Please try again.</li>'); | |
}, | |
timeout: 3000, | |
beforeSend: function() { | |
$('#tour').addClass('is-fetching'); | |
}, | |
complete: function() { | |
$('#tour').removeClass('is-fetching'); | |
} | |
}); | |
} | |
}; | |
$(document).ready(function() { | |
tour.init(); | |
}); | |
var kingKong = { | |
blastoff: function() { | |
var clickMoster = $(".clickster"); | |
clickMoster.on("click", this.fetchBitch); | |
}, | |
fetchBitch: function(){ | |
alert("Death to everyone bitch"); | |
} | |
}; | |
$(document).ready(function() { | |
tour.init(); | |
kingKong.blastoff(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment