These are chat archives for canjs/canjs

15th
Jun 2017
Nico R.
@nriesco
Jun 15 2017 07:28
Is it possible to use custom headers with Can’s Ajax? (https://canjs.com/doc/can-util/dom/ajax/ajax.html) I tried adding a headers field but seems that it won’t consider them
Brad Momberger
@bmomberger-bitovi
Jun 15 2017 15:05
can.ajax doesn't do custom headers, but you can use jQuery.ajax in place of it (including in can-connect) if you need those extra things
craigoshima
@craigoshima
Jun 15 2017 15:23
Hey y'all. Former user of CanJS v1. About to start a new project, and considering what framework to use. Quick question: I see that 3.x no longer supports can.view() to load a template from a URL. I assume there's a good reason for that. Is there a blog post or something that explains the rationale and the alternative(s)? Thanks!
(There will probably be more questions from me in the next or so, as I look into all the changes.) :-)
Brad Momberger
@bmomberger-bitovi
Jun 15 2017 15:25
Our module loader is now sufficiently advanced so the view templating engine doesn't need to handle downloading from remote sources.
craigoshima
@craigoshima
Jun 15 2017 15:25
Module loader meaning stealjs?
Brad Momberger
@bmomberger-bitovi
Jun 15 2017 15:25
Whereas before you had to do can.view("/path/to/my/mustache") you can now just write import myStache from 'path/to/my/stache!';
yep, and steal-stache takes care of parsing it into a render function for you.
craigoshima
@craigoshima
Jun 15 2017 15:27
Ah, ES6. I've been away from coding for a few years (doing UI design instead). I've already started looking at ES6. Was planning to skip stealjs because I wanted to limit myself to CanJS, but maybe I should reconsider. Thanks!
(I'm missing EJS too.) :-)
Brad Momberger
@bmomberger-bitovi
Jun 15 2017 15:28
You can also use CommonJS format if you feel more comfortable with that (we support both)
craigoshima
@craigoshima
Jun 15 2017 15:29
I'll keep that in mind. I expect I should get comfy with ES6 anyway :-)
Actually, as long as you're here, another question: event handlers used to be on the Controller instance. In a 3.x Component, should they be on the viewModel (DefineMap) or on the component's "events" object? Does it matter? Is there a best practice? Thanks!
Kevin Phillips
@phillipskevin
Jun 15 2017 15:34
Check out https://donejs.com/. It will get you started with stealjs/canjs.
normally, in 3.x, the functions would be on the ViewModel and called using can-stache-bindings.
Brad Momberger
@bmomberger-bitovi
Jun 15 2017 15:34
:point_up: this.
Kevin Phillips
@phillipskevin
Jun 15 2017 15:34
it is much easier to write tests for code written that way
craigoshima
@craigoshima
Jun 15 2017 15:34
Yeah, I was hoping to stick with just CanJS, but I've started looking at the guides on DoneJS.
Cool. Thanks all!
(A lot has changed since JMVC!)
Brad Momberger
@bmomberger-bitovi
Jun 15 2017 15:35
This is very true.
Kevin Phillips
@phillipskevin
Jun 15 2017 15:36
if it hadn't, would you be considering using it still? :wink:
Brad Momberger
@bmomberger-bitovi
Jun 15 2017 15:37
Some things will still feel familiar (can-construct still works the same way, models will still have save(), stache works mostly like mustache), but making components with the modlet pattern is way friendlier now IMO.
Also we have autorender now, which lets you do the entire page as a stache template.
craigoshima
@craigoshima
Jun 15 2017 15:44
Well, JMVC and CanJS 1.x worked well for me in the past, and I would consider using the old version because I have code that I could easily re-use immediately. Now I need to learn new stuff, like how the old concepts map to the new (I've already looked at the migration page; I bookmarked it :-)
Anyway, no big deal, just a consideration. Thanks again! I'm sure y'all will be hearing more from me! :-)