DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
    • can-component
    • can-compute
    • can-connect
    • can-define
    • can-define/list/list
    • can-define/map/map
    • can-route
      • static
        • current
        • data
        • deparam
        • link
        • matched
        • param
        • ready
        • url
    • can-route-pushstate
    • can-set
    • can-stache
    • can-stache/helpers/route
    • can-stache-bindings
  • Ecosystem
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Core
  • /
  • can-route
  • /
  • url
  • / On this page
    • url

      function

      Creates a URL fragment based on registered routes given a set of data.

      • source

      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.

      route.url({ page: "home" });
      // -> "#!page=home"
      

      Parameters

      1. data {Object}:

        The data to populate the route with.

      2. merge {Boolean}:

        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, route.url creates only the URL based on the route options passed into it.

      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.

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

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.