DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
  • Infrastructure
    • can-construct
    • can-control
    • can-event
    • can-event/async/async
    • can-event/batch/batch
    • can-observation
    • can-simple-map
    • can-util
    • can-view-callbacks
    • can-view-live
    • can-view-model
    • can-view-nodelist
    • can-view-parser
    • can-view-scope
    • can-view-target
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Infrastructure
  • /
  • can-view-target
  • / On this page
    • can-view-target

      module
      • npm package badge
      • Star
      • source

      target(nodes)

      Create a document fragment that can be cloned but have callbacks be called quickly on elements within the cloned fragment.

      var viewTarget = require("can-view-target");
      
      var target = viewTarget([
          {
              tag: "h1",
              callbacks: [function(data){
                  this.className = data.className
              }],
              children: [
                  "Hello ",
                  function(){
                      this.nodeValue = data.message
                  }
              ]
          },
      ]);
      
      // target.clone -> <h1>|Hello||</h1>
      // target.paths -> path: [0], callbacks: [], children: {paths: [1], callbacks:[function(){}]}
      
      var frag = target.hydrate({className: "title", message: "World"});
      
      frag //-> <h1 class='title'>Hello World</h1>
      

      Parameters

      1. nodes {Array}:

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