Skip to content

Instantly share code, notes, and snippets.

@terrancebryant
Created October 25, 2013 21:10
Show Gist options
  • Save terrancebryant/7161891 to your computer and use it in GitHub Desktop.
Save terrancebryant/7161891 to your computer and use it in GitHub Desktop.
<!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>
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