These are chat archives for canjs/canjs

9th
Apr 2015
dylanrtt
@dylanrtt
Apr 09 2015 13:37
@matthewp the docs say can-import only works with can.autorender which I am not using... does that mean the only option is to include my components everywhere in my js?
Chris Gomez
@akagomez
Apr 09 2015 16:18
@justinbmeyer How much slower is map.attr('property') than map.property?
For simple values (not computes).
Matthew Phillips
@matthewp
Apr 09 2015 16:51
@dylanrtt it doesn't only work with autorender, where do the docs say that?
Currently this only works with can.autorender and the system plugin
Matthew Phillips
@matthewp
Apr 09 2015 17:00
Thanks, that's not true though, it works with Stache
With Steal/System, RequireJS, even Browserify
i'll update the docs
autorender is not required
well let me correct that, it works with the System plugin
everywhere
So if you're using steal you're fine, but if you're using requirejs it only works with autorender
dylanrtt
@dylanrtt
Apr 09 2015 17:04
ah, thanks for clearing that up
Matthew Phillips
@matthewp
Apr 09 2015 17:07
Let me correct that again, <can-import> does not work with Require, someone would have to create a Require plugin to make it work
Sorry, I was confusing autorender and can-import
Let me say it again more clearly...
<can-import> works with Stache and Steal/SystemJS.
But does not require that you use autorender.
dylanrtt
@dylanrtt
Apr 09 2015 17:13
ok so I am using Stache with Steal and scanner says no custom element was found for can-import... do I need to add an include for it to recognize can-import?
or maybe the github version of canjs is missing the system plugin
you guys said to use the bower version before but it was missing some files
Matthew Phillips
@matthewp
Apr 09 2015 17:16
The warning is probably something we've failed to account for
are you importing your template with steal?
var template = require("./template.stache!")
dylanrtt
@dylanrtt
Apr 09 2015 17:17
well I just have it in a script tag for now to test but I believe I tried that too
ok I actually get a different issue when loading the stache template through another file through steal. the error only happens when I put can-import in the template. "Cannot read property 'pop' of undefined" on html_seciton.js:78:22
Matthew Phillips
@matthewp
Apr 09 2015 17:21
which version of can?
dylanrtt
@dylanrtt
Apr 09 2015 17:22
both 2.2.0 and 2.2.4
Matthew Phillips
@matthewp
Apr 09 2015 17:22
if you have it in a script tag you do need to use autorender
or you can use can.stache.async
var renderer = can.stache.async(source)
although i think that's undocumented... let me look
yeah it's not documented but it works
returns a deferred
can.stache.async(source).then(function(renderer) {
dylanrtt
@dylanrtt
Apr 09 2015 17:35
well I'm no longer using the script tag and it seems to throw the error simply while loading the view through steal. is the file I am loading through can-import supposed to return something? (it's a custom attr so there's nothing to return)
dylanrtt
@dylanrtt
Apr 09 2015 17:57
well if I can't use can-import, then I need another way to make sure my custom attr works in my templates, and right now it isn't
I tried adding the attr in the steal dependencies of the can.Control that renders the template that has the custom attr but that doesn't even work
Matthew Phillips
@matthewp
Apr 09 2015 19:28
Sorry, was away. Can you reproduce in a fiddle?
What is the error that throws?
dylanrtt
@dylanrtt
Apr 09 2015 19:41
I'll see if I can get a fiddle going but it's tricky with steal, can and a separate stache file. I posted the error up above a few hours ago, which happens when it parses the can-import tag
I'd love if you could show me a full of example of it actually working somewhere because the docs only show snippets
Matthew Phillips
@matthewp
Apr 09 2015 19:44
pull that down, npm install and load bit-tabs.html in your browser
dylanrtt
@dylanrtt
Apr 09 2015 20:49
ok omg I guess I was using <can-import></can-import> instead of just <can-import/> which are naturally synonymous to me so I didn't notice they were different
Matthew Phillips
@matthewp
Apr 09 2015 20:49
ah :(
dylanrtt
@dylanrtt
Apr 09 2015 20:56
anyway, I can't upgrade to Stache just yet so I applied an ugly hack where I redefined can/view/bindings in my steal config to point to a custom file that loads the original and then my other custom attrs. it'll work for now and enables the global loading...
Matthew Phillips
@matthewp
Apr 09 2015 20:59
That sort of thing works up until a point but doesn't scale to a large app
you wind up loading a lot of stuff, all of the time
dylanrtt
@dylanrtt
Apr 09 2015 21:00
yeah I just found out it broke my build lol
Kyle Gifford
@kylegifford
Apr 09 2015 22:54
how do I listen for an "add" event triggered by a can.List.replace?
specifically inside a can.Component events object
Kyle Gifford
@kylegifford
Apr 09 2015 23:17
looks like I figured it out. you have to put your full event target inside braces
"{scope.placements} add": function() { ... }
where placements is a can.List that could be .replace()'d