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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 8 CREATING MOBILE WEB APPSvar cheeseModel = {};detectDeviceFeatures(function(deviceConfig) {cheeseModel.device = deviceConfig;checkForVersionPreference();$.getJSON("products.json", function(data) {cheeseModel.products = data;enhanceViewModel();$(document).ready(function() {ko.applyBindings(cheeseModel);$('*.deferred').each(function(index, elem) {ko.applyBindings(cheeseModel, elem);});$('button.left, button.right').live("click", function(e) {e.preventDefault();advanceCategory(e, $(e.target).hasClass("left")? "left" : "right");$.mobile.changePage($('div[data-category="'+ cheeseModel.selectedCategory() + '"]'));})$.mobile.initializePage();hasher.initialized.add(crossroads.parse, crossroads);hasher.changed.add(crossroads.parse, crossroads);hasher.init();crossroads.addRoute("category/:newCat:", function(newCat) {cheeseModel.selectedCategory(newCat ||cheeseModel.products[0].category);});crossroads.addRoute("{shortCat}", function(shortCat) {$.each(cheeseModel.products, function(index, item) {if (item.shortName == shortCat) {crossroads.parse("category/" + item.category);}});});crossroads.parse(location.hash.slice(1));});});});

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

Saved successfully!

Ooh no, something went wrong!