DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
    • can-construct-super
    • can-define-stream
    • can-fixture
    • can-fixture-socket
    • can-jquery
    • can-stache-converters
      • Pages
        • select[multiple]
        • input[type=checkbox]
        • input[type=radio]
        • select
      • Converters
        • boolean-to-inList
        • either-or
        • equal
        • index-to-selected
        • not
        • string-to-any
    • can-stream
    • can-vdom
    • can-view-import
    • can-zone
    • steal-stache
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Ecosystem
  • /
  • can-stache-converters
  • /
  • select[multiple]
  • / On this page
    • select[multiple]

      function

      Cross bind a value to a <select> element with multiple selections permitted.

      • source

      <select multiple {($values)}="KEY"/>

      Cross binds the selected option values with an observable value.

      Parameters

      1. KEY {can.stache.key}:

        A named value in the current scope. KEY's value is cross bound with the selected <option> in the <select>. KEY's value should be an Array-like, or undefined.

      Use

      Select elements with the multiple attribute (<select multiple {($values)}="KEY"/>) have a specified behavior if the value of KEY is Array like, or undefined.

      Cross binding to Arrays

      <select> tags with a multiple attribute cross bind a can-map property, compute or can-list in sync with the selected items of the <select> element.

      For example, the following template:

      <select multiple {($values)}="colors">
        <option value='red'>Red</option>
        <option value='green'>Green</option>
        <option value='yellow'>Yellow</option>
      </select>
      

      Could be rendered with one of the following:

      // A can-map property
      new DefineMap({colors: []})
      
      // A compute
      { colors: compute([]) }
      
      // A DefineList
      { colors: new DefineList() }
      

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