Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,43 @@ var AppRouter = Backbone.Router.extend({
},

changePage:function (page) {
var options = {
changeHash: false,
};

$(page.el).attr('data-role', 'page');
page.render();
$('body').append($(page.el));
var transition = $.mobile.defaultPageTransition;

// We don't want to slide the first page
if (this.firstPage) {
transition = 'none';
options.transition = 'none';
this.firstPage = false;
}
$.mobile.changePage($(page.el), {changeHash:false, transition: transition});

// Find the anchor that triggered this page change and mix-in the relevant data attributes
else if (this.clickedAnchor) {
_.extend({
reverse: (this.clickedAnchor.data().direction === 'reverse'),
transition: this.clickedAnchor.data().transition
}, options);

this.clickedAnchor = null;
}

$.mobile.changePage($(page.el), options);
}

});

$(document).ready(function () {
console.log('document ready');
app = new AppRouter();

// Bind to click events so we can store the anchor that triggered the page change.
$(document).bind("click", function(event) {
app.clickedAnchor = $(event.target).closest('a');
});

Backbone.history.start();
});