I’d like to be able to do something like the following though…
$('#btnId').click({foo:'bar'});
Template.foo.events({
'click #btnId'(e, template) {
const foo = params.foo;
console.log(`you clicked the btn and its data is ${foo}`);
}
});
However, passing in that Object as a param makes it so that the even doesn’t even get called! Strangely, there’s no console errors. I’m thinking it might have something to do with a Template Event.
Second, even though Blaze and jQuery do work together for certain things, event handling doesn’t seem to be part of that. What is it you actually want to do? Who/what issues the click event? Where are the parameters you want to add coming from?
In the Template.event handler you always have the event.currentTarget object
I want a template event handler of a parent template to click btn in a child template (thus executing the child template’s event handler) I want the params coming from the parent template’s event handler (it’s to make the child event handler execute another code path).
I think this use-case is going beyond how Meteor (Blaze) and jQuery work together. Meteor uses different patterns to communicate between parent and child templates. I would check out the blazejs documentation to get some ideas