Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 16:04
    yayan19 starred canjs/canjs
  • Oct 20 02:45
    AkiaCode starred canjs/canjs
  • Oct 19 14:39
    hkutcher opened #5510
  • Oct 19 14:38
  • Oct 17 10:58
    Fatima-Usf starred canjs/canjs
  • Oct 15 21:18
    naskio starred canjs/canjs
  • Oct 12 22:08
    cherifGsoul synchronize #5509
  • Oct 12 22:08

    cherifGsoul on upgrade-can-ajax

    xvfb services (compare)

  • Oct 12 22:07
    cherifGsoul edited #5509
  • Oct 12 22:06
    cherifGsoul opened #5509
  • Oct 12 22:01

    cherifGsoul on upgrade-can-ajax

    Update can-ajax version (compare)

  • Sep 29 13:17
    ko25july starred canjs/canjs
  • Sep 21 17:41
    cherifGsoul assigned #5508
  • Sep 21 17:39
    cherifGsoul opened #5508
  • Sep 18 19:32
  • Sep 11 02:59
    torongu starred canjs/canjs
  • Sep 09 06:57
    tbreuss starred canjs/canjs
  • Sep 04 18:58
    cherifGsoul review_requested #5507
  • Sep 04 18:58
    cherifGsoul opened #5507
  • Sep 04 18:51

    cherifGsoul on post-release-script

    Add GitHub release automation (compare)

Kevin Phillips
@phillipskevin
please feel free to open issues
Christopher Oliphant
@RALifeCoach

I’m back. I am trying to fire an event. Inside the component I have:

        events: {
            'highlightplayer': function () {
                debugger;
            },

and in the parent module I have:

$(#myId’).trigger(‘highlightplayer’);

I also tried:

can.event.dispatch.call($(‘myId’), ‘highlightplayer’);
myId is assigned in the stache fragment for the component
Mohamed Cherif Bouchelaghem
@cherifGsoul
'#myId highlightplayer': function () {
                debugger;
            },
Christopher Oliphant
@RALifeCoach
okay - I used it without the #myId because the docs say:
events: {
    "click" : function(){
      var currentMessage = this.viewModel.attr("message");
      this.viewModel.attr("message", currentMessage+ "!")
    }
  }
Mohamed Cherif Bouchelaghem
@cherifGsoul
It listens to click event on the component tag
Christopher Oliphant
@RALifeCoach
The id in my case isn’t fixed. It is actually ‘xxx-‘ + pid
Mohamed Cherif Bouchelaghem
@cherifGsoul
use classes
class="js-my-el"
'.js-my-el highlightplayer': function () {
                debugger;
            }
Kevin Phillips
@phillipskevin
you can put the event in your template also
Christopher Oliphant
@RALifeCoach
but the component is repeated many times on the page - therefore the class would be repeated
Kevin Phillips
@phillipskevin
($highlightPlayer)=“highlightPlayer”
Christopher Oliphant
@RALifeCoach
I only want the change to apply to this row
that’s why the id is distinct
@phillipskevin isn’t that discouraged due to the performance impact?
Kevin Phillips
@phillipskevin
only if you’re going to have thousands of this component
Christopher Oliphant
@RALifeCoach
If I specify it as you indicated, then I can use the event as shown above?
Kevin Phillips
@phillipskevin
if you do it that way, highlightPlayer would be a function on your viewmodel
Christopher Oliphant
@RALifeCoach
and how do I fire it as an event from outside the component?
$.trigger
or can.trigger
Christopher Oliphant
@RALifeCoach
Kevin Phillips
@phillipskevin
no, it doesn't
the ($highlight)=“highlight” has to be on the same element you’re triggering the event on
Christopher Oliphant
@RALifeCoach
right - thanks
Kevin Phillips
@phillipskevin
no problem
Thomas Sieverding
@Bajix
@RALifeCoach How’s the project coming along?
Thomas Sieverding
@Bajix
How do I read/write to the root scope w/in a component
Thomas Sieverding
@Bajix
How does %root work?
dylanrtt
@dylanrtt
@Bajix %root is just a child map of all components' viewmodels, so you can do this.attr('%root.foo') or this.attr('%root.foo', bar)
Thomas Sieverding
@Bajix
dylanrtt
@dylanrtt
are you asking how to use it in a template?
Thomas Sieverding
@Bajix
yes
My impression was that I’d be able to do <foo *bar> … {{*bar.someProp}} ..</foo>
I’m a little confused though, as I had expected %root.bar to be set as the exported vm
dylanrtt
@dylanrtt
scope lookups to component viewmodels don't fall-through to %root if that's what you are thinking
whereas scope in the template does (not sure if I said that right)
Thomas Sieverding
@Bajix
I see - I had thought %root was the template scope
dylanrtt
@dylanrtt
This message was deleted
Thomas Sieverding
@Bajix
%root is the top most ref?
So if you’re doing leakScope: false, then child components would have %root === the vm of the parent
dylanrtt
@dylanrtt
yes, the top most ref
shouldn't matter with leakScope:whatever
Thomas Sieverding
@Bajix
That’s inconsistent w/ the docs. *bar should be the vm itself
dylanrtt
@dylanrtt
oh sorry my bad, I don't usually use that syntax
Thomas Sieverding
@Bajix
Well, leakScope would just mean that it’s now the top most ref
So if I had <my-app *app><my-service>{{>views/index}}</my-service></my-app>, shouldn’t I be able to do {{*app.foo}} within index?
dylanrtt
@dylanrtt
I don't think so. *app would only be available within the outer template. They are not passed down