url

  • function
can.route.url  

can.route.url( data [, merge] )

Make a URL fragment that when set to window.location.hash will update can.route's properties to match those in data.

Parameters

  1. data {Object}

    The data to populate the route with.

  2. merge {Boolean}Optional

    Whether the given options should be merged into the current state of the route.

Returns

{String}

The route URL and query string.

Similar to link, but instead of creating an anchor tag, can.route.url creates only the URL based on the route options passed into it.

can.route.url( { type: "videos", id: 5 } )
     // -> "#!type=videos&id=5"

If a route matching the provided data is found the URL is built from the data. Any remaining data is added at the end of the URL as & separated key/value parameters.

can.route(":type/:id")

can.route.url( { type: "videos", id: 5 } ) // -> "#!videos/5"
can.route.url( { type: "video", id: 5, isNew: false } )
     // -> "#!video/5&isNew=false"