These are chat archives for canjs/canjs

27th
Apr 2017
Gira Minus
@gKreator
Apr 27 2017 04:49
image.png
that is my parent
image.png
that is my child
image.png
im trying to pass a function from my child component to be used on my parent component, but it always returns null on the parent and it never executes it
any clue on why that is?
my side bar wont resize :/
image.png
re-scale*
Eben
@eben-roux
Apr 27 2017 07:01
I guess another way to get to what I'm doing is doing the binding through code.
I'd like to specify username once and then bind it to my value and also bind to the username in my errors list from the validation.
Jeroen Cornelissen
@jeroencornelissen
Apr 27 2017 08:25

Is the first argument in %arguments always the event?
Child component:
this.dispatch('savesorting', [{item: this.item}]);

Stache:
(savesorting)=“saveSorting(%arguments)”

Parent component:
saveSorting : function(args)
args[0] = the savesorting event
args[1] = object.item

Szabolcs Schmidt
@sszabolcs
Apr 27 2017 08:36
@roemhildtg @tescalle I also use CanJS 3 in AMD format. Here are the build scripts I use to build it.
Szabolcs Schmidt
@sszabolcs
Apr 27 2017 08:42
There is one caveat: jquery imports result in 'jquery/dist/jquery' references, you have to replace these references to simply 'jquery'.
Gregg Roemhildt
@roemhildtg
Apr 27 2017 14:23
@sszabolcs thanks for posting that
Gira Minus
@gKreator
Apr 27 2017 14:27
@phillipskevin you've helped me with the above before but for some reason i cant get it to work :/
Kevin Phillips
@phillipskevin
Apr 27 2017 14:28
{^@unassigned_route_resize}="unassigned_route_resize" is the part that’s not working?
Eben
@eben-roux
Apr 27 2017 14:30
Is there a sample app somewhere that I uses can-route? I don't seem to find anything useful on GitHub and the guides don't illustrate this either.
Kevin Phillips
@phillipskevin
Apr 27 2017 14:30
the JSBin at the top uses can-route
Eben
@eben-roux
Apr 27 2017 14:31
at the top of?
Kevin Phillips
@phillipskevin
Apr 27 2017 14:31
there’s a link at the top of Gitter
Eben
@eben-roux
Apr 27 2017 14:32
ah
Eben
@eben-roux
Apr 27 2017 14:40
I'm having issue trying to get the route to work properly: http://forums.donejs.com/t/hash-change-not-picked-up-on-route/624
I'd like to only process once when the values on the route change
Justin suggested using a compute to get the change that delegate used to do in 2.3 but I don't quite understand how to set that up
Gira Minus
@gKreator
Apr 27 2017 14:43
@phillipskevin yeah it seems to not be working at all, the var is still null on parent
Eben
@eben-roux
Apr 27 2017 14:43
Also, I have a boostrap navigation going and when I click on a dropdown then the url changes instead of dropping the menu:
blob
blob
Eben
@eben-roux
Apr 27 2017 15:11
@gKreator : shouldn't it perhaps be {^unassigned_route_resize}="@unassigned_route_resize"... if memory serves the @ is a function pointer marker of sorts
Gira Minus
@gKreator
Apr 27 2017 15:21
Yeah i think i tried that, ill have to try that again later
Brad Momberger
@bmomberger-bitovi
Apr 27 2017 16:02
@gKreator can you examine the viewModel that's on the can-import tag? I have a feeling this may be a scope issue.
Gira Minus
@gKreator
Apr 27 2017 16:10
I will tonight, im at work ill have to bother you all later :)
I can pass everything but a function to the parent
Nico R.
@nriesco
Apr 27 2017 18:52
is this ok?
Name1: {{name}}<br>
{{#with newMainModel}}
  Name2 (newMainModel.name): {{name}}<br>
  Name1 (parent): {{../name}}<br>
{{/with}}
my question is, when using {{#with something}} anything inside of it is withing the something scope? can I use ../ to access the original scope?
I ask this because a more complex version of this is not working as expected and just wanted to check that I’ve got the basics covered correctly
Brad Momberger
@bmomberger-bitovi
Apr 27 2017 18:56
The docs as written imply that that should work as you expect.
"{{#with}} renders a subsection with a new context added to the can-view-scope" from http://canjs.com/doc/can-stache.helpers.with.html
Nico R.
@nriesco
Apr 27 2017 19:02
@chasenlehara it says {{./name}} why not just {{name}}?
Chasen Le Hara
@chasenlehara
Apr 27 2017 19:17
You could do that, but ./ enforces lookup in only the current context.
Nico R.
@nriesco
Apr 27 2017 19:18
so even if leakScope is off, it will try to look name in the parent context? (using {{name}})?
that seems odd
Chasen Le Hara
@chasenlehara
Apr 27 2017 19:19
No, but let’s say you were listing out all the todos for a person:
Todos for {{name}}:
{{#each todos}}
    <div class='{{#if ../isEditing(this)}}editing{{/if}}'>
        {{./name}}
    </div>
{{/each}}
If one of the todos didn’t have a name, it would correctly display nothing instead of the person’s name.
I personally think it’s better to use #each todos as todoand todo.name, but you can do whatever floats your boat.
Nico R.
@nriesco
Apr 27 2017 19:36
ok, now I understand, thanks
Chasen Le Hara
@chasenlehara
Apr 27 2017 19:40
👍
Gira Minus
@gKreator
Apr 27 2017 23:24
@bmomberger-bitovi ran some test looks like child properties do not get to the parent via stach-bindings
Brad Momberger
@bmomberger-bitovi
Apr 27 2017 23:26
Can you tell if they're set anywhere??
I was wondering if the can-import tag might be interfering with the binding by adding its own scope
Gira Minus
@gKreator
Apr 27 2017 23:27
yeah on the child compoent on the init event i do console.log( this.viewModel.test ); and the value is a 'test1' string
that would be possible but annoying lol
Brad Momberger
@bmomberger-bitovi
Apr 27 2017 23:29
Right, but at least it might be addressable then.
Gira Minus
@gKreator
Apr 27 2017 23:29
yes
let me try that
Brad Momberger
@bmomberger-bitovi
Apr 27 2017 23:29
{^@unassigned_route_resize}="%scope._parent.unassigned_route_resize"
or possibly {^@unassigned_route_resize}="../unassigned_route_resize"
Gira Minus
@gKreator
Apr 27 2017 23:32
:D the first one crashed the app on boot pretty much, but the second one looks good so far
kinda explains why it was working on the jsbin
Brad Momberger
@bmomberger-bitovi
Apr 27 2017 23:36
Yeah, sometimes it's the subtle things. BTW, i think it's possible to use the non-containing can-import syntax even in your case.
Which might have avoided the issue.
Gira Minus
@gKreator
Apr 27 2017 23:37
hmm? non-containing can-import syntax? there is such a thing?
Brad Momberger
@bmomberger-bitovi
Apr 27 2017 23:38
<can-import from="./unassigned_route" {^value}="*unassignedRoute" />
{{#if *unassignedRoute}}<component-dashboard-unassigned-route ... />{{/if}}
The * is to stick the value on (and read from) the reference scope
...which can be used to pass stuff around a stache without setting anything on the view model.