根据值将 <span> 图标传递给 html 表

问题描述

我正在获取 json 数据并从中创建一个表。一列是关于优先级的,我想用图标替换获取的数字。我已经看到一些解决方案之后用 jquery 更改了 html,但这对我来说似乎不对。相反,我想在创建表格时设置图标。

以下相关代码片段:

行模板:

<script type="text/underscore-template" id="caseTableRow">
<tr><td><a href="https://..."+ ><%=json.id%></a></td>
<td><%=json.title%></td>
<td><%=json.priority_id%></td> // display an icon instead
<td><%=json.refs%></td></tr>

渲染中:

$.each(cases,function(index,$testrailcase) {
                    var casesTable = $('#casesTable');
                    casesTable.append(that.rowTemplate({testrailcase: $testrailcase}));
                });

在行模板中:

rowTemplate: function(testrailcase) {
            return _.template($('#caseTableRow').html())(testrailcase,icon);
        },

我想集成的 Atlassian-Icons 格式如下:

<span class="aui-icon aui-icon-small aui-iconfont-arrow-down-circle">Insert meaningful text here for accessibility</span>

我很乐意提供任何帮助 :D

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)