These are chat archives for canjs/canjs

14th
Feb 2019
apsignifi
@apsignifi
Feb 14 16:58
can4 - changing call expression syntax.
would {{#each .}} change to {{#each(.)}} ?
Kevin Phillips
@phillipskevin
Feb 14 18:13
yeah, or {{#each(this)}}
either works
apsignifi
@apsignifi
Feb 14 18:17
@phillipskevin Thanks.
can4 : is this valid ?
{{^if(../../action)}}
Virendra Kumar
@virendrak-dev
Feb 14 18:18
@phillipskevin please help me for the issue related with inserted event in single page component.
Kevin Phillips
@phillipskevin
Feb 14 18:23
@apsignifi that is valid, yes
you can do {{scope.log()}} to see what the scope looks like
@virendrak-dev what is the issue?
Virendra Kumar
@virendrak-dev
Feb 14 18:24
in Can2 we use inerted event
events: {
"inserted": function() {
this.viewModel.initDatePicker();
this.viewModel.initTimePicker();
}
}
then how we can use this event in .component file
?
I have a jquery datepicker plugin and I want to initialize in .component file
image.png
apsignifi
@apsignifi
Feb 14 18:30

@phillipskevin : Thanks.

@apsignifi that is valid, yes

Virendra Kumar
@virendrak-dev
Feb 14 18:31
above is the screenshot of code and it doesn't work, how I can call the initDatePicker() in inserted event?
above syntax for inerted event does'nt work.
Kevin Phillips
@phillipskevin
Feb 14 18:31
<script type="events">
        export default {
            click: function(){
                this.viewModel.attr("visible", !this.viewModel.attr("visible"))
            }
        };
</script>
that's how you do events in a .component
https://github.com/donejs/done-component is the best place to find out about .componentfiles
Virendra Kumar
@virendrak-dev
Feb 14 18:34
nice! it works. Thanks you so much @phillipskevin .
Kevin Phillips
@phillipskevin
Feb 14 18:34
you're welcome
apsignifi
@apsignifi
Feb 14 18:52

can4 : I have a helper :

stache.registerHelper('isActive', function(value, level, options) {

    if (typeof value == 'function') {
        value = value();
    }

    var context = options.scope.get(level);

   // if there is no current active panel (there isnt one on initialize) then we set the first loaded panel to active

    if (context.active_panel === null || typeof context.active_panel == 'undefined' ) {
        context.active_panel = value ;
    }

    if (context.active_panel === value ) { 
        return options.fn(context);
    } 
    else {
        return options.inverse(context);
    }

});

from migration perspective, do I need to change from
{{#isActive scope.index '../'}} to {{#isActive(scope.index, '../')}}
?

Chasen Le Hara
@chasenlehara
Feb 14 21:40
@apsignifi I think this part of the migration guide helps clarify that https://canjs.com/doc/migrate-4.html
The exception is built-in helpers or Helper Expressions (when called with >=1 argument). This is so that many changes for helpers like {{#each items}} or {{#eq value1 value2}} do not hinder upgradability.
BTW, sorry we haven’t been as responsive on here, there’s way more people hanging out in the Slack: https://bitovi.com/community/slack