120 likes | 475 Views
KendoUI Routing and SPA. Using KendoUI for SPA Applications. Learning & Development. http://schoolacademy.telerik.com. Telerik School Academy. Table of Contents. Kendo MVVM Views and ViewModels Kendo Router Defining routes Routes with parameters Creating SPA apps with KendoUI
E N D
KendoUI Routing and SPA Using KendoUI for SPA Applications Learning & Development http://schoolacademy.telerik.com Telerik School Academy
Table of Contents • Kendo MVVM • Views and ViewModels • Kendo Router • Defining routes • Routes with parameters • Creating SPA apps with KendoUI • Creating Views and ViewModels • Defining routes
Kendo MVVM Just a recap
Kendo MVVM • KendoUI has a powerful MVVM framework • Views – kendo.View • ViewModels – kendo.observable • Kendo Views Layout var layout = new kendo.Layout('…'), viewModel = kendo.observable({ title: 'Welcome to the Online video player' }), view = new kendo.View('…', { model: viewModel}); layout.render('#root'); layout.showIn('#view', view);
Kendo MVVM Live Demo
Kendo Router The creation of fake pages
Routing • Routing is the way to create different pages in SPA apps • The pages are not real pages, but look like real • Different pages have different hash (#) suffix • Instead of http://site.com/home.htmlthe url is http://site.com/index.html/#home • Why use routes? • Routes present better end-user experience • The copy&paste of an ULR works • The end-user has history • Etc…
Kendo Router • The router supports routing in KendoUI apps • Initialized with newkendo.Router() • Routes are added with .route(string, callback) • Each route has a function callback, that is executed when the route is reached • Executed with .start() var router = new kendo.Router(); router.route('/', showHome); router.route('/home', showHome); router.route('/about', showAbout); router.start();
Routes in KendoUI Live Demo
Routing and SPA http://academy.Telerik.com
Homework • Create a SPA application for chatting • Use a SaaS cloud provider • Both Telerik Backend Services or Parse will do • Users can register/login • The username is unique • Allusers chat in a single channel • All users see the all messages
Homework (2) • (cont.) Create a SPA application for chatting • Implement it using KendoUI MVVM and Router • The application should have three different pages (routes) • Homepage • Show information about the Web app • Login/register page • Login/register user • Chat page • Show messages from other users • Send new message