Skip to content

Instantly share code, notes, and snippets.

@amcdnl
Last active December 10, 2015 20:08
Show Gist options
  • Save amcdnl/4486381 to your computer and use it in GitHub Desktop.
Save amcdnl/4486381 to your computer and use it in GitHub Desktop.

Upgrade your JMVC to CanJS/JMVC 3.3

A informal guide to things that have changed over the past versions and how you can get your project up to snuff.

New

These aren't necessarily new features but things were there in some capacity before but expanded upon in latest.

  • Model.List is now available for Observes
  • You can call methods directly from templated bindings. F example: "resize":function() { this.updateUI() }); could now be just "resize": "updateUI"
  • instances() and instance() can be called on observes.

Removed

These are things that have been completely removed and you will need to either make mappings for or update.

  • Remove $ in function($) from steal function callbacks
  • this.find is gone, use this.element.find in controls
  • attrs is now just attr
  • jQuery plugins are not automatically hooked up, you have to include can/control/plugin
  • .super and .proxy are no longer included by default
  • <%== view('myejs', {}) %> is no longer there, just use <%== can.view.render() %>
  • You should no longer use this in EJS when referring to the this context, it is implied.
  • You can no longer init a list with a collection or item like: var list = new Twitter.Models.Item.List(item)

Changed

Things that have been there but the API is slightly different.

  • this.Class is now this.constructor
  • In EJS <%== plugin('fun_menu', {}) %> would now be <%== (el)->el.fun_menu() %>
  • this.callback is now this.proxy
  • .model() and .models() for dom hookup is now .instance() and .instances()
  • this.view in can/control/view returns a document fragment not a DOM node.
  • Models must return deferreds
  • steal.options is moved to steal.config()
  • steal.root is moved to steal.config().root
  • If you override the success property of ajax calls in models, you models will NOT be piped through to be wrapped and added to lists.
  • Model.List.get has changed from accepting the whole object to just the id. Example: Model.List.get(id)
  • this.bind in control is now this.on
  • List.each used to be index, itemItterating, now its opposite.

Deprecated

These are still present but should be removed soon.

  • Remove .then() from steal
  • listensTo is gone in controls. Just listen for the events using event delegation
  • can.Control.extend() the extend part is no longer needed; just do can.Control()

Older

You've probably already done these but just in case.

  • <%= %> will now escape and <%== %> is unescaped
  • can.Control({}, {}) no longer has to have both if you only want the prototype you can do can.Control({})

New Mappings

These should be obvious but just in case.

  • $.Class is now can.Construct
  • $.Controller is now can.Control
  • $.route is now can.route
  • $.Model is now can.Model

Mappings

MXUI is now called canui. You can remap this easily in the stealconfig.js file.

steal.config({
  map: {
    "*": {
      "mxui/": "canui/"
    }
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment