javascript - Equivalent of jQuery's $(this) in Ractive.js event proxies -
i reading ractive.js event proxies here.
i want replace click event (currently written in jquery) event proxy in ractive.js. current code:
$('.filter-close').click(function(){ $(this).parent().hide(); });
the html bit easy:
<a on-click="closefilter" class="filter-close">close</a>
and know how create proxy in ractive.js:
ractive.on( 'closefilter', function ( event ) { //code here });
if place alert in there, executes correctly on click.
the problem i'm running is, how access element itself. in example above, need hide parent of clicked element. in jquery used $(this)
find element. how do same in ractive?
this
returns entire ractive object, $(this)
throws error, , fetching element id, think, defeats purpose of using ractive in first place.
i'm aware of possibility pass argument along event, on-click="closefilter:{{arg}}"
, don't know arg
should in case (or if correct approach @ all).
can point me in right direction here?
event.node
gives access dom element
ractive.on( 'activate', function ( event ) { // event.node button (will <button on-click='activate'>activate!</button>) });
to access parent node can event.node.parentnode
if have jquery on page can $(event.node.parentnode).hide();
Comments
Post a Comment