These are chat archives for canjs/canjs

18th
Aug 2015
Andrei Balmus
@abalmush
Aug 18 2015 14:59

Gusy, please help: Is it possible to set current context to a custom attribut of the Component? just Like this:

{{#products}}
    <product productdata={{.}}></product>
{{/products}}

inside product Component I’m getting ‘[object Object]’ :(

oh forgot to tell you, I’m using stache
Aggelos Karalias
@mehiel
Aug 18 2015 15:03
@abalmush try productdata="{.}"
Andrei Balmus
@abalmush
Aug 18 2015 15:04
@mehiel ok thanks!
Andrei Balmus
@abalmush
Aug 18 2015 15:27
@mehiel, {.} doesnt work for me, it’s just renders ‘{.}'
I just created jsfiddle to test: https://jsfiddle.net/ghdc74gx/
Aggelos Karalias
@mehiel
Aug 18 2015 15:36
that's because of prod: '@'
can you remove that and try again
Andrei Balmus
@abalmush
Aug 18 2015 15:37
sure one sec
yes it works now @mehiel thank you so much!!
Aggelos Karalias
@mehiel
Aug 18 2015 15:38

from viewModel's doc

Prototype properties that have values of "@" are not looked up in the current viewModel

Andrei Balmus
@abalmush
Aug 18 2015 15:41
allright, i used only string before so didnt have any issues, but now I need object and you save my life, thank you!
espretto
@espretto
Aug 18 2015 20:18
quick question: would one produce zombie views if a components template changed? i have a large app which loads components only when needed and one parent component to manage that like so:
Component.extend({
    tag: 'oa-articles',
    leakScope: true,
    scope: {
      // articles: <model>,
      request: compute(function () {
        var scope = this;
        ArticleModel.findAll({
          categoryId: scope.attr('categoryId')
        }).then(function (articles) {
          scope.attr('articles', articles);
        });  
      })
    },
    events: {
      // request's dependency tracking for `categoryId` is only set-up when bound
      '{scope} request': function () {},

      '{scope} articles': function (ctx, evt, articles) {
        var $elem = this.element,
                tags = articles.pluck('tag');
        $.when(tags.map(function (tag) {
          return requestComponentByTag(tag);
        }).then(function () {
          $elem.html(tags.map(function (tag) {
            return '<'+tag+'></'+tag'>';
           }).join(''));
        });
      }
    }
  });
});