Skip to content
Browse files

Fixed the require-js example

  • Loading branch information...
1 parent 8c9a944 commit e5b48a39fdbffabf5d26649f4e2d7a070f6dd970 @azicchetti committed Feb 5, 2012
View
2 examples/backbone-requirejs-example/js/main.js
@@ -8,7 +8,7 @@ require.config({
jqmr : 'libs/jquery.mobile.router',
app : 'src/app',
'collection.data' : 'src/collection/data',
- 'view.detail' : 'src/view/detail'
+ 'view.detail' : 'src/view/Detail'
}
});
View
13 examples/backbone-requirejs-example/js/src/app.js
@@ -27,7 +27,7 @@ define(['collection.data', 'view.detail'],
}
if (!ExampleNS.V.detail) {
ExampleNS.V.detail = new DetailView({
- model : ExampleNS.M.data, detailId : null, el : $("#detail :jqmData(role='content')")
+ collection: ExampleNS.M.data, detailId : null, el : $("#detail :jqmData(role='content')")
});
}
var params = ExampleNS.C.router.getParams(match[1]);
@@ -41,7 +41,11 @@ define(['collection.data', 'view.detail'],
ExampleNS.V.detail.render();
}
- }
+ },
+
+ pageInit : function (type, match, ui, page) {
+ console.log("This page ("+$(page).jqmData("url")+") has been initialized");
+ }
}
};
@@ -51,7 +55,10 @@ define(['collection.data', 'view.detail'],
},
"#detail([?].*)?" : {
handler : ExampleNS.C.renderDetail, events : "bs"
- }
+ },
+ ".": {
+ handler : ExampleNS.C.pageInit, events: "i"
+ }
});
// in order to prevent foc
View
16 examples/backbone-requirejs-example/js/src/example.js
@@ -52,8 +52,8 @@ C.renderForm = function (type, match, ui) {
console.log('renderForm - #dynForm id: ' + C.router.getParams(match[1]).formId);
};
-C.renderPage = function (type, match, ui) {
- console.log('render Page - #dynForm id: ' + C.router.getParams(match[1]).formId);
+C.pageInit = function (type, match, ui, page) {
+ console.log('This page '+$(page).jqmData("url")+" has been initialized");
};
@@ -63,11 +63,11 @@ C.router=new $.mobile.Router({
"#detail([?].*)?": {
handler: C.renderDetail, events: "bs"
},
- "#dynForm([?].*)?" : {
- handler : C.renderForm, events : "bs"
- },
- ".": {
- handler: "C.renderPage", events: "bc"
- }
+ "#dynForm([?].*)?" : {
+ handler : C.renderForm, events : "bs"
+ },
+ ".": {
+ handler: C.pageInit, events: "i"
+ }
});
View
5 examples/backbone-requirejs-example/js/src/view/Detail.js
@@ -8,18 +8,17 @@ define([],
template : _.template('<div class="id">Id: <%= id %></div><div class="title">Titolo: <%= title %></div><div class="text">Testo: <%= text %></div>'),
initialize : function () {
- this.model.bind("reset", this.render, this);
+ this.collection.bind("reset", this.render, this);
},
render : function () {
if (!this.options.detailId) {
return;
}
- var reqInstance = this.model.get(this.options.detailId);
+ var reqInstance = this.collection.get(this.options.detailId);
if (!reqInstance) {
return;
}
- /* mhm? */
this.el.html(this.template(reqInstance.toJSON()));
return this;
}

0 comments on commit e5b48a3

Please sign in to comment.
Something went wrong with that request. Please try again.