I'm starting a new project and would like to use Kendo's SPA along with RequireJS for the design; however, I'm running into a roadblock that I just can't get by and I'm hoping someone here has dealt with it in the past. My issue comes down to passing route parameters to a view for rendering. My current sample code is as follows:
main.js
app.js
ListController.js
My goal is to use the ListController for the various js logic for creating various kendo widgets for the view I'm trying to render; however, If I can't find a good way to pass parameters along to use with my future datasource calls I going to be stuck. Any push in the right direction here would be greatly appreciated.
Thanks,
-Brendan
main.js
(function () {
require.config({
deps: ["js/jquery"]
});
require(['app'], function(App){
App.start();
});
})();
app.js
define([
'kendo/js/kendo.all.min',
'controllers/ListController'
], function (kendo, list) {
var router = new kendo.Router({
routeMissing: function (e) {
console.log('No Route Found', e.url);
}
});
router.route("list/(:id)", function(id) {
var myIdParameter = id;
// TODO Find a way to pass the myIdParameter to the view I'm about to render.
// Render the view in the "app" div
list.render("#app");
});
return router;
});
ListController.js
define(['kendo/js/kendo.all.min'], function (kendo) {
// TODO I would like to have the "1234" value passed from the route parameter
var viewModel = kendo.observable({
id: "1234"
});
var options = {
model: viewModel
};
return new kendo.View(
"index",
options
);
});
My goal is to use the ListController for the various js logic for creating various kendo widgets for the view I'm trying to render; however, If I can't find a good way to pass parameters along to use with my future datasource calls I going to be stuck. Any push in the right direction here would be greatly appreciated.
Thanks,
-Brendan