12.07.2015 Views

Pro JavaScript for Web Apps pdf - EBook Free Download

Pro JavaScript for Web Apps pdf - EBook Free Download

Pro JavaScript for Web Apps pdf - EBook Free Download

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 5 CREATING OFFLINE WEB APPSListing 5-10. Adding an Ajax GET RequestRequest...var cheeseModel = {cache: {status: ko.observable(window.applicationCache.status),online: ko.observable(window.navigator.onLine)}};$.getJSON("products.json", function(data) {cheeseModel.products = data;}).success(function() {$(document).ready(function() {$('#buttonDiv input:submit').button();$('div.navSelectors').buttonset();enhanceViewModel();ko.applyBindings(cheeseModel);hasher.initialized.add(crossroads.parse, crossroads);hasher.changed.add(crossroads.parse, crossroads);hasher.init();crossroads.addRoute("category/:cat:", function(cat) {cheeseModel.selectedCategory(cat || cheeseModel.products[0].category);});$(window.applicationCache).bind("checking noupdate downloading " +"progress cached updateready", function(e) {cheeseModel.cache.status(window.applicationCache.status);});$(window).bind("online offline", function() {cheeseModel.cache.online(window.navigator.onLine);});$('div.tagcontainer a').button().filter(':not([href])').click(function(e) {e.preventDefault();if ($(this).attr("data-action") == "update") {window.applicationCache.update();} else {window.applicationCache.swapCache();window.location.reload(false);}});});});...130www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!