【发布时间】:2016-07-28 19:41:30
【问题描述】:
我已经有一段时间没有运气了,所以我想我会在 SO 上抛出一些东西。
只有当源来自tbody 而不是thead 时,我才需要执行单击事件的功能和Angular 指令。我尝试了多种途径来获取此信息,但我似乎无法正确使用语法。
任何帮助/指导将不胜感激。这是我最新/最好的尝试。会告诉你我要做什么:
/* Linker for the directive */
var linker = function (scope, elm, attrs) {
window.setTimeout(function(){
elm.find('table tbody tr.uib-weeks td button span.text-info').closest('tr').find('button').addClass('chosenReportWeek');
}, 1000); // This is a hack until we can find the proper load/render event
elm.on('click', function(event) {
if(event.target.parent.indexOf('thead') === -1){
elm.find('table tbody tr.uib-weeks button.active').closest('tr').find('button').addClass('chosenReportWeek');
}
});
};
【问题讨论】:
-
if ( $(event.target).closest('tbody').length ) {... -
必须在
.closest中将其更改为'thead,但它可以工作。谢谢!
标签: javascript angularjs angularjs-directive onclick dom-events