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.
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).
Add the functionality to allow urls to have parameters within them. ex:
#!/user/23
Theuser
is the page, and23
is a parameter, not a new page.To handle this a few things must be done:
The
page
binding could accept a new parameter calledurlParams
which is an array of strings, that provide thekey
for the sequentialvals
in the url. ex:<div data-bind="page: {id: 'test', urlParams: ['userId']}"></div>
Then within the
navigate
function, before calling upon thechild
page to navigate, the current page would extract out the nexturlParams.length
crumbs, and create akey/val
object. It would then combine this object with thequeryString
parameters, and pass this as a request to the server. ex:#!/user/23/settings
. Theuser
page would extract23
asuserId
, and then call thesettings
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 acsthml
orphp
type file). TheviewModel
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 firebeforeSourceReload
andafterSourceReload
.