【问题标题】:Highlight row is not getting disappear after I click the next table row单击下一个表格行后,突出显示行没有消失
【发布时间】:2019-02-10 14:07:28
【问题描述】:

在为表格行中的菜单选项选择齿轮图标时,我需要将背景创建为黄色,我尝试了以下代码来突出显示表格行,

var view = Core.view.Menu.create({
    model: model,
    menuContext: { ibmm: ibmm },
    anchor: this.$(),
    highlight: this.$().parents('tr:first').css('background-color','yellow')
});
view.show();

从带有齿轮图标的表格行(隐藏)中选择菜单时,背景颜色很好。

[![在此处输入图片描述][1]][1]

对应的html文件如下

<tr id="ember23242" class="ember-view content-row body-row-view container-view" tabindex="0" aria-label="">

但是当我移动到下一个表格行(非隐藏)时,过去的表格行颜色仍然是黄色,没有消失。

[![在此处输入图片描述][2]][2]

当我单击行时,我正在使用下面的 css 代码来创建突出显示

table.content-table.highlighted tr.content-row:focus {
  background: #FFFF99 none 0 0 repeat;
}

任何人都可以建议我为此编写代码。我使用的是 Ember 1.4.0。

【问题讨论】:

  • 你能说明你在下一个表格行的情况吗?
  • 请稍候@BhushanKawadkar,我将在我的问题中进行编辑
  • 当您选择另一个表格行时,是否会触发任何行事件?可以分享相关的html代码吗?
  • 没有@BhushanKawadkar,没有触发行事件。等我添加html和css代码
  • 嗨@BhushanKawadkar,我已编辑。 'ember-view content-row body-row-view container-view' 这对所有表格行都是通用的

标签: javascript jquery css ember.js ember-1


【解决方案1】:

你可以尝试下面的 jquery 来重置你的背景颜色,事件将发生在 focusout 上。

$(function(){
  $("table.content-table.highlighted tr.content-row").on("focusout", function(){
        $(this).css('background','#FFFF00 none 0 0 repeat'); // change color code as per your need
  });
});

【讨论】:

  • 当我添加此代码时,现有的表格行也没有消失。你能再检查一次吗
  • 我需要删除这个 .css('background-color','yellow')
  • 这不起作用。你能建议我一些其他的代码吗
  • 您能否在代码片段或 jsfiddle 上重新创建您的问题,以便我查看它
【解决方案2】:

检查:first:first-child之间的区别

var view = Core.view.Menu.create({
    model: model,
    menuContext: { ibmm: ibmm },
    anchor: this.$(),
    highlight: this.$().parents('tr:first-child').css('background-color','yellow')
});
view.show();

【讨论】:

  • 嗨@Arthur。当我尝试您的代码时,当我单击菜单时甚至没有显示背景颜色。请查看我的更新问题
猜你喜欢
  • 1970-01-01
  • 2017-09-21
  • 2011-05-03
  • 2012-04-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-04
  • 1970-01-01
相关资源
最近更新 更多