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
  • /
  • current
  • / On this page
    • current

      function

      Check if data represents the current route.

      • source

      route.current(data [,subsetMatch] )

      Compares data to the current route. Used to verify if an object is representative of the current route.

      route.data.set({page: "recipes", id: '5'});
      
      route.current({page: "recipes"});       //-> false
      route.current({page: "recipes"}, true); //-> true
      

      Parameters

      1. data {Object}:

        Data to check agains the current route.

      2. subsetMatch {Boolean}:

        If true, route.current will return true if every value in data matches the current route data, even if the route data has additional properties that are not matched. Defaults to false where every property needs to be present.

      Returns

      {Boolean}:

      Whether the data matches the current URL.

      Use

      Checks the page's current URL to see if the route represents the options passed into the function.

      Returns true if the options represent the current URL.

      route.data.id = 5; // location.hash -> "#!id=5"
      route.current({ id: 5 }); // -> true
      route.current({ id: 5, type: 'videos' }); // -> false
      
      route.data.type = 'videos';
        // location.hash -> #!id=5&type=videos
      route.current({ id: 5, type: 'videos' }); // -> true
      

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