Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Demos: Fix backbone-requirejs demo acc. to new api #8477

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions build/tasks/options/spider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ module.exports = {
url: "http://localhost:" + "<%= phpPort %>",
ignore:
"api\\.jquerymobile\\.com/accordion|notapage|intel|" +
"api\\.jquerymobile\\.com/[0-9]\\.[0-9]|packt|twitter\\.com/jquery"
"api\\.jquerymobile\\.com/[0-9]\\.[0-9]|packt|twitter\\.com/jquery|" +
"demos/backbone\-requirejs/backbone\-require\.html"
}
},
"dist": {
options: {
url: "http://localhost:" + "<%= phpPort %>" + "/dist/",
ignore:
"api\\.jquerymobile\\.com/accordion|notapage|intel|" +
"api\\.jquerymobile\\.com/[0-9]\\.[0-9]|packt|twitter\\.com/jquery"
"api\\.jquerymobile\\.com/[0-9]\\.[0-9]|packt|twitter\\.com/jquery|" +
"demos/backbone\-requirejs/backbone\-require\.html"
}
}
};
6 changes: 4 additions & 2 deletions demos/backbone-requirejs/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ require([
)

require( [ "jquerymobile" ], function () {
$( "body" ).one( "pagecontainerchange", function() {

// Instantiates a new Backbone.js Mobile Router
this.router = new Mobile();
// Instantiates a new Backbone.js Mobile Router
this.router = new Mobile();
} );
});
});
21 changes: 11 additions & 10 deletions demos/backbone-requirejs/js/routers/mobileRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ define([

// Extends Backbone.Router
var CategoryRouter = Backbone.Router.extend( {
backToHome: false,

// The Router constructor
initialize: function() {

this.pagecontainer = $( ".ui-pagecontainer" ).pagecontainer( "instance" );
this.pagecontainerHandle = $( ".ui-pagecontainer" );

// Instantiates a new Animal Category View
this.animalsView = new CategoryView( { el: "#animals", collection: new CategoriesCollection( [] , { type: "animals" } ) } );
Expand All @@ -27,9 +28,9 @@ define([
// Instantiates a new Vehicles Category View
this.vehiclesView = new CategoryView( { el: "#vehicles", collection: new CategoriesCollection( [] , { type: "vehicles" } ) } );


// Tells Backbone to start watching for hashchange events
Backbone.history.start();

},

// Backbone.js Routes
Expand All @@ -47,21 +48,21 @@ define([
home: function() {

// Programatically changes to the categories page
this.pagecontainer.change( "#categories", {
this.pagecontainerHandle.pagecontainer( "change", "#categories", {
reverse: false,
changeHash: false
changeUrl: false
});

},

// Category method that passes in the type that is appended to the url hash
category: function(type) {

// Stores the current Category View inside of the currentView variable
var currentView = this[ type + "View" ];
var that = this;

// If there are no collections in the current Category View
if(!currentView.collection.length) {
if( !currentView.collection.length ) {

// Show's the jQuery Mobile loading icon
$.mobile.loading( "show" );
Expand All @@ -70,9 +71,9 @@ define([
currentView.collection.fetch().done( function() {

// Programatically changes to the current categories page
this.pagecontainer.change( "#" + type, {
that.pagecontainerHandle.pagecontainer( "change", "#" + type, {
reverse: false,
changeHash: false
changeUrl: false
});
} );

Expand All @@ -82,9 +83,9 @@ define([
else {

// Programatically changes to the current categories page
this.pagecontainer.change( "#" + type, {
this.pagecontainerHandle.pagecontainer( "change", "#" + type, {
reverse: false,
changeHash: false
changeUrl: false
});

}
Expand Down