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
      • Modules
        • ./legacy
      • Methods
        • viewModel
    • can-stache-converters
    • 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-jquery
  • /
  • ./legacy
  • / On this page
    • can-jquery/legacy

      module

      Enables legacy integrations between CanJS and jQuery. Importing can/jquery/legacy will return the jQuery object. It will also import can-jquery so that the event system hooks are set up.

      Additionally it will force element callbacks (such as those in can-control) to be jQuery wrapped.

      var $ = require("can-jquery/legacy");
      
      • source

      jQuery

      Importing can-jquery/legacy will also bring in can-jquery, but also has the side effect of enabling jQuery wrappers being applied to places such as can-controls and (event) callbacks.

      Note that simply importing can-jquery-legacy will enable this, so any can-controls expecting to receive the raw HTMLElement will break.

      var $ = require("can-jquery/legacy");
      var Control = require("can-control");
      
      var MyControl = Control.extend({
          "li click": function(el){
              // `el` is jQuery wrapped!
          }
      });
      
      var dom = $("<div><ul><li>First</li><li>Second</li></ul></div>");
      new MyControl(dom);
      
      dom.find("li:first").trigger("click");
      

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