finnsson / pagerjs

The Single Page Application Framework for KnockoutJS
http://pagerjs.com/
MIT License
272 stars 68 forks source link

Route management? ( Phonegap / Webapp) #103

Closed kokujin closed 11 years ago

kokujin commented 11 years ago

I have been using a mix of Path.js(https://github.com/mtrpcic/pathjs) and Express.js routes for my application. Express.js defines a few "hard" routes like login, logout, backend API and the domain root. Path.js does the client side part need for the single page app and Phonegap.

What is the preferred Pagerjs way to manage and structure routes and viewmodels?

Thanks!

finnsson commented 11 years ago

I would say it depends on the size of the pages and view models. I usually have something like

var viewModel = {
    fooViewModel: new FooViewModel(),
    barViewModel: new BarViewModel()
}

and then

<div data-bind="page: {id: 'foo', with: fooViewModel, source: 'foo.html'}"></div>
<div data-bind="page: {id: 'bar', with: barViewModel, source: 'bar.html'}"></div>

for the larger view models/pages. I think some prefer to keep the config-object (id: 'foo', ...} in the view model instead and then just writing page: fooPage. I'm not sure which way is best.