Skip to content Skip to sidebar Skip to footer

Is It Possible To Use Nested Selectors In Meteor Event Maps?

Here, I would like to select the .accept element from within the .header element. Is this possible? The documentation is inconclusive and I have tried some variations to no avail,

Solution 1:

What you shared will work assuming you don't have a conflict elsewhere. Try using the code below. The event fires only if you click the second div, as you want.

template:

<body>
    {{> page}}
</body><templatename="page"><divclass="header">.header 
        <divclass="accept">.header .accept</div></div></template>

js:

if (Meteor.isClient) {
    Template.page.events({
        'click .header .accept': function(event) {
            console.log('accept clicked');
        }
    });
}

Post a Comment for "Is It Possible To Use Nested Selectors In Meteor Event Maps?"