These are chat archives for canjs/canjs

29th
Apr 2015
largoelks
@largoelks
Apr 29 2015 15:39
With a can.Component is there a way to have multiple <content> elements and assign content to each?
Or am I limited to a single <content></content>
David Luecke
@daffl
Apr 29 2015 15:44
There is no content select implemented yet.
David Luecke
@daffl
Apr 29 2015 16:08
@largoelks Here is the issue: bitovi/canjs#500
largoelks
@largoelks
Apr 29 2015 16:11
@daffl Thanks I'll check that out. Even basic support would allow much more expressive components
Matthew Phillips
@matthewp
Apr 29 2015 16:12
content select is still very much up in the air from a spec perspective
largoelks
@largoelks
Apr 29 2015 16:18
It seems like it would be valuable. We use bootstrap and even for simple components like a panel. It can have a panel-header, panel-body and panel-footer, plus lists and tables. It'd be nice to re-position that content. Of course I can do that with the inserted event
Matthew Phillips
@matthewp
Apr 29 2015 16:19
oh for sure it's valuable
David Luecke
@daffl
Apr 29 2015 16:19
It's not just the spec, it turned out that it's quite hard to implement as well (which is probably why the spec isn't finalized)
Matthew Phillips
@matthewp
Apr 29 2015 16:19
We had a prototype that kind of worked, just not well in older IE
largoelks
@largoelks
Apr 29 2015 16:25
From your experience do you end up nesting lots of small components or making one big simpler component that has lots of <content> html, to work around. So for the panel example. Either a panel component with a sub heading, body and footer component. Or just a panel component and the html designer dumps in all required html for all different designs?
Marshall Thompson
@marshallswain
Apr 29 2015 18:47
@matthewp Nice work on live-reload. It’s really, really fast.
Matthew Phillips
@matthewp
Apr 29 2015 18:47
using it already huh? :)
Marshall Thompson
@marshallswain
Apr 29 2015 18:48
Getting it set up right now.
Matthew Phillips
@matthewp
Apr 29 2015 18:48
cool, getting ready to post an article
Marshall Thompson
@marshallswain
Apr 29 2015 18:48
Trying to figure out how to get my components to reload properly.
without creating duplicates in memory.
Matthew Phillips
@matthewp
Apr 29 2015 18:49
what do you mean?
oh, you mean your can.components?
Marshall Thompson
@marshallswain
Apr 29 2015 18:50
yeah.
Matthew Phillips
@matthewp
Apr 29 2015 18:50
i don't think there will be duplicates, it overwrites the previous
Marshall Thompson
@marshallswain
Apr 29 2015 18:51
Hmmm. Maybe I’m using $().append() and getting multiple in the DOM.
Matthew Phillips
@matthewp
Apr 29 2015 18:51
yeah
that can happen
so there are 2 options
reload.dispose(function() { $("#main").remove(); })
will remove it when that module is being torn down
or you can just have an <div id="app></div>
on your page
and use $("#app").html(renderer())
then you don't have to worry about tearing down the previous
Marshall Thompson
@marshallswain
Apr 29 2015 18:53
renderer() is a call to something like can.view()?
in your example
Matthew Phillips
@matthewp
Apr 29 2015 18:54
yeah
there's a simple example there
i'll push to steal-can-example, which uses .dispose
Marshall Thompson
@marshallswain
Apr 29 2015 18:55
Cool. Thanks.
I’ll study it.
I’m super excited for this.
Marshall Thompson
@marshallswain
Apr 29 2015 19:03
Is there a way to re-execute can.route.ready()?
I want to re-initialize the routes after a live-reload.
David Luecke
@daffl
Apr 29 2015 19:23
Does calling it again not re-execute
?
Marshall Thompson
@marshallswain
Apr 29 2015 19:32
import reload from 'live-reload';
reload(function(){
  can.route.ready();
});
Does nothing
Doing this as a workaround:
reload(function(){
  var pg = appState.attr('page');
  appState.removeAttr('page');
  appState.attr('page', pg);
});
Matthew Phillips
@matthewp
Apr 29 2015 19:34
why do you need to do that again?
Marshall Thompson
@marshallswain
Apr 29 2015 19:36
I’m placing a component in a container based on the route’s page attribute.
// Hook up routes to page components.
appState.bind('page', function(ev, newVal){
  if(newVal) {
    var template =  '<page-'+newVal+'></page-'+newVal+'>';
    $('#page-container').html(  can.stache( template )( appState ) );
  }
});
Matthew Phillips
@matthewp
Apr 29 2015 19:37
oh
so what i did in steal-can-example... one sec
i just moved that out to a render() function
maybe not the best way, but avoids this issue you are seeing
then you can just run reload(render)
Marshall Thompson
@marshallswain
Apr 29 2015 19:39
I see. Thanks.
So there’s not currently a way to re-fire the can.route events? At least, I don’t see one documented.
I was hoping that maybe there was an undocumented, existing option.
Matthew Phillips
@matthewp
Apr 29 2015 19:43
maybe try can.route.setState()
blind guess
Marshall Thompson
@marshallswain
Apr 29 2015 19:45
Thanks. I’ll have a look at it and see what I can find.
Matthew Phillips
@matthewp
Apr 29 2015 19:46
are you wanting to add routes?
that would be nice
we might have to update can to make it live-reload aware
or have a plugin
can-live-reload
Marshall Thompson
@marshallswain
Apr 29 2015 19:49
Yeah. It would be ideal to have a plugin that automagically took care of it, so there would be no need for workarounds in the code… since I’ll be using this all the time.
Matthew Phillips
@matthewp
Apr 29 2015 19:50
let me know if that works
Stan Carrico
@shcarrico
Apr 29 2015 21:37
hi @matthewp
i notice that "can" in NPM seems to be stale
it is returning 2.3.0-pre.0
is this a known thing? and, will NPM in future contain only CJS module format, or will it have all 3 or ? :)
David Luecke
@daffl
Apr 29 2015 21:48
2.3.0-pre.0 is stale? It should be the 2.3 prerelease. And does and will contain all formats just like 2.2
Stan Carrico
@shcarrico
Apr 29 2015 21:53
i thought current version is 2.5 ?
Alexis Abril
@alexisabril
Apr 29 2015 21:54
2.2.5
Stan Carrico
@shcarrico
Apr 29 2015 21:54
what i get when i do "npm install can" does not have all formats. it only has steal format, at the root.
sorry 2.2.5
i got confused on the digits.
oh, i see.. its in the "dist" folder?
Alexis Abril
@alexisabril
Apr 29 2015 21:55
yeah, at the root it’ll have the steal format(I believe going forward @matthewp can confirm)
but the dist will have everything
Stan Carrico
@shcarrico
Apr 29 2015 21:55
ok. so different than bower ?
Alexis Abril
@alexisabril
Apr 29 2015 21:55
we’re consolidating bower to use the same dist, but it’s different for the moment
Stan Carrico
@shcarrico
Apr 29 2015 21:56
arighty.
Alexis Abril
@alexisabril
Apr 29 2015 21:56
the npm install is from the actual canjs repo; bower is actually the tarball dist from canjs.com
Stan Carrico
@shcarrico
Apr 29 2015 21:58
sounds good. i got the version straight now and i get the 'dist' thing. thanks for clearing it up
David Luecke
@daffl
Apr 29 2015 22:19
Also, the NPM install should come with the Browserify mappings to dist/cjs so there shouldn't be any configuration necessary there.