These are chat archives for ractivejs/ractive

12th
Aug 2017
Santo
@santochen
Aug 12 2017 06:23
Hi @fskreuz , i'm having difficulty creating the sample for the issues (the event hookup was working).
The logic was to use tether to display a list of dropdown actions (which has on-click), after tether, those on-click no longer working so I'm trying to create a decorator, managed to hook up a click, is there a way in the decorator to get the on-click and the expression so that i can fire it manually on the ractive node?
Santo
@santochen
Aug 12 2017 06:58
basically how do I fire manually on-click event in decorator
kouts
@kouts
Aug 12 2017 07:01
@santochen inside a decorator you bind an event with vanilla javascript (ie addEventListener) unless I'm missing something
Chris Reeves
@evs-chris
Aug 12 2017 07:02
you can trigger an event directive from a context with raise
Santo
@santochen
Aug 12 2017 07:03
I have defined in the element with something like <a on-click="@this.testM(.)"> , is there a way to just fire that on-click manually from decorator?
so @evs-chris , @kouts , I have node from decorator.. do I use node.addEventListener or node.raise ?
Chris Reeves
@evs-chris
Aug 12 2017 07:05
this.getContext(node).raise('click') will cause testM to be called
Santo
@santochen
Aug 12 2017 07:06
Thanks @evs-chris , will try that :)
Chris Reeves
@evs-chris
Aug 12 2017 07:07
you may have to provide an event object, which can be empty... my memory is a little fuzzy, but hopefully it's in the api docs
Santo
@santochen
Aug 12 2017 07:23
omg it works! thanks guys!!!! :grin:
Chris Reeves
@evs-chris
Aug 12 2017 07:25
:+1:
kouts
@kouts
Aug 12 2017 07:27
I didn't knew you can do that! Another hidden Ractive gem, thank you @evs-chris !
kouts
@kouts
Aug 12 2017 07:49
I just did a small test and you can also raise a non-existent dummy event, it doesn't have to be a click!
Santo
@santochen
Aug 12 2017 07:50
so that means we could raise a different event to our liking then?
kouts
@kouts
Aug 12 2017 07:52
Yes, I just did an example with a bootstrap collapse decorator I have in hand and I raise a shown event
e.g this.getContext(node).raise('shown');
and in the template:
on-shown="@global.console.log('Shown!')"
Santo
@santochen
Aug 12 2017 08:03
nice!