DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
  • Infrastructure
  • Legacy
    • can-ejs
    • can-list
    • can-map
    • can-map-backup
    • can-map-define
    • can-view-href
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Legacy
  • /
  • can-view-href
  • / On this page
    • can-view-href

      module

      Sets an element's href attribute so that it's url will set the specified attribute values on can-route.

      • npm package badge
      • Star
      • source

      Deprecated 2.3

      Use the routeUrl helper instead like: href="{{routeUrl prop=value}}".

      can-href='{[attrName=attrValue...]}'

      Parameters

      1. attrName {String}:
      2. attrValue {KeyLookup Expression}:

      Use

      With no pretty routing rules, the following:

      <li><a can-href='{page="recipe" id=5}'>{{recipe.name}}</a></li>
      

      produces:

      <li><a href='#!&page=5&id=5'>{{recipe.name}}</a></li>
      

      If pretty route is defined like:

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

      The previous use of can-href will instead produce:

      <li><a href='#!page/5'>{{recipe.name}}</a></li>
      

      You can use values from stache's scope like:

      <li><a can-href='{page="recipe" id=recipeId}'>{{recipe.name}}</a></li>
      

      If recipeId was 6:

      <li><a href='#!page/6'>{{recipe.name}}</a></li>
      

      If recipeId is observable and changes to 7:

      <li><a href='#!page/7'>{{recipe.name}}</a></li>
      

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