简体   繁体   English

“ click html / deep / #id”在MeteorJS模板事件处理程序中不起作用

[英]“click html /deep/ #id” not working in MeteorJS template event handler

i want to trigger click event on shadow-dom polymer element 我想在shadow-dom聚合物元素上触发click事件

document.querySelector("html /deep/ #main-toolbar-toggle") is correctly pick the corresponding shadow-dom polymer element but "click html /deep/ #main-toolbar-toggle": function(event, target) { in meteor template event handler is not work document.querySelector("html /deep/ #main-toolbar-toggle")正确选择了相应的shadow-dom聚合物元素,但"click html /deep/ #main-toolbar-toggle": function(event, target) {在流星模板事件处理程序不起作用

Template.layout_linto.events({

"click html /deep/ #main-toolbar-toggle": function(event, target) {
    alert("ok");

what r the correct syntax to do it using meteor template event handler ? 使用流星模板事件处理程序执行此操作的正确语法是什么?

You have to use a selector in relation to the template not the page. 您必须相对于模板而不是页面使用选择器。 The template is in a scope that cannot access the page's html. 模板位于无法访问页面html的范围内。

This is better: 这个更好:

Template.layout_linto.events({

"click #main-toolbar-toggle": function(event, target) {
    alert("ok");

}});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM