pandell / Spagety

Other
0 stars 0 forks source link

Url Parameters & queryStrings #4

Open cjasinsk opened 10 years ago

cjasinsk commented 10 years ago

Add the functionality to allow urls to have parameters within them. ex: #!/user/23 The user is the page, and 23 is a parameter, not a new page.

To handle this a few things must be done:

The page binding could accept a new parameter called urlParams which is an array of strings, that provide the key for the sequential vals in the url. ex: <div data-bind="page: {id: 'test', urlParams: ['userId']}"></div>

Then within the navigate function, before calling upon the child page to navigate, the current page would extract out the next urlParams.length crumbs, and create a key/val object. It would then combine this object with the queryString parameters, and pass this as a request to the server. ex: #!/user/23/settings. The user page would extract 23 as userId, and then call the settings child page.

We would need to store the values for each navigation, and if they change then request from the server again. These parameters would be sent to the html file, to do server side validation first (in a csthml or php type file). The viewModel would also need to be re-initialized if the parameters changed.

When reloading these resources, a check for isRedirecting should be done as well, as well as perhaps additional events to fire beforeSourceReload and afterSourceReload.

101100 commented 10 years ago

It might also be useful to be able to pass these parameters to the view model instead of to the web request. This would allow cached pages with dynamic data (as we do now with our overall pages).