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

Commit ba76873

Browse files
apsdehalarschmitz
authored andcommitted
Demos: Fix backbone requirejs demos acc to new api
Closes #8477 Ignore backbone demos from spider
1 parent da5b421 commit ba76873

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

build/tasks/options/spider.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ module.exports = {
44
url: "http://localhost:" + "<%= phpPort %>",
55
ignore:
66
"api\\.jquerymobile\\.com/accordion|notapage|intel|" +
7-
"api\\.jquerymobile\\.com/[0-9]\\.[0-9]|packt|twitter\\.com/jquery"
7+
"api\\.jquerymobile\\.com/[0-9]\\.[0-9]|packt|twitter\\.com/jquery|" +
8+
"demos/backbone\-requirejs/backbone\-require\.html"
89
}
910
},
1011
"dist": {
1112
options: {
1213
url: "http://localhost:" + "<%= phpPort %>" + "/dist/",
1314
ignore:
1415
"api\\.jquerymobile\\.com/accordion|notapage|intel|" +
15-
"api\\.jquerymobile\\.com/[0-9]\\.[0-9]|packt|twitter\\.com/jquery"
16+
"api\\.jquerymobile\\.com/[0-9]\\.[0-9]|packt|twitter\\.com/jquery|" +
17+
"demos/backbone\-requirejs/backbone\-require\.html"
1618
}
1719
}
1820
};

demos/backbone-requirejs/js/main.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ require([
4848
)
4949

5050
require( [ "jquerymobile" ], function () {
51+
$( "body" ).one( "pagecontainerchange", function() {
5152

52-
// Instantiates a new Backbone.js Mobile Router
53-
this.router = new Mobile();
53+
// Instantiates a new Backbone.js Mobile Router
54+
this.router = new Mobile();
55+
} );
5456
});
5557
});

demos/backbone-requirejs/js/routers/mobileRouter.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ define([
1212

1313
// Extends Backbone.Router
1414
var CategoryRouter = Backbone.Router.extend( {
15+
backToHome: false,
1516

1617
// The Router constructor
1718
initialize: function() {
1819

19-
this.pagecontainer = $( ".ui-pagecontainer" ).pagecontainer( "instance" );
20+
this.pagecontainerHandle = $( ".ui-pagecontainer" );
2021

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

31+
3032
// Tells Backbone to start watching for hashchange events
3133
Backbone.history.start();
32-
3334
},
3435

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

4950
// Programatically changes to the categories page
50-
this.pagecontainer.change( "#categories", {
51+
this.pagecontainerHandle.pagecontainer( "change", "#categories", {
5152
reverse: false,
52-
changeHash: false
53+
changeUrl: false
5354
});
54-
5555
},
5656

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

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

6364
// If there are no collections in the current Category View
64-
if(!currentView.collection.length) {
65+
if( !currentView.collection.length ) {
6566

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

7273
// Programatically changes to the current categories page
73-
this.pagecontainer.change( "#" + type, {
74+
that.pagecontainerHandle.pagecontainer( "change", "#" + type, {
7475
reverse: false,
75-
changeHash: false
76+
changeUrl: false
7677
});
7778
} );
7879

@@ -82,9 +83,9 @@ define([
8283
else {
8384

8485
// Programatically changes to the current categories page
85-
this.pagecontainer.change( "#" + type, {
86+
this.pagecontainerHandle.pagecontainer( "change", "#" + type, {
8687
reverse: false,
87-
changeHash: false
88+
changeUrl: false
8889
});
8990

9091
}

0 commit comments

Comments
 (0)