根据记录状态的特定值(“ACTIVE”与“INACTIVE”),我想给下拉结果的每条记录一定的背景颜色。怎么办?我尝试了下面的内容:
JSON:
hooks/post_gen_project.py
JS:
# coding: utf-8
from __future__ import print_function, unicode_literals
import io
import os
def convert_resources(src_dir):
if "src" in os.listdir(src_dir):
src_dir = os.path.join(src_dir, "src")
print("src_dir: " + src_dir)
for root_dir, dirnames, filenames in os.walk(src_dir):
for filename in filenames:
ext = os.path.splitext(filename)[1]
if ext in ('.ini', '.php'):
src_path = os.path.join(root_dir, filename)
print(" Converting '{relpath}'...".format(relpath=os.path.relpath(src_path, src_dir)))
with io.open(src_path, mode="r", encoding="utf-8") as fd:
content = fd.read()
with io.open(src_path, mode="w", encoding="iso-8859-1") as fd:
fd.write(content)
if __name__ == '__main__':
convert_resources(os.getcwd())
答案 0 :(得分:1)
return
在它到达if( item.status...)
之前,因此永远不会评估此代码。考虑将标记构建为字符串,然后在完成后返回html字符串。active
元素中添加inactive
或<li>
类,然后css规则.active { background-color: #eaffd6; } .inactive { background-color: #ffe5e5 }
编辑您可以尝试类似
的内容 $(this).data('ui-autocomplete')._renderItem = function (ul, item) {
var str_html = '<li class="' + item.status.toLowerCase() + '">'
+ '<a href="/"' + item.id + '" >' + item.label + '</a>'
+ '</li>'
return str_html''
};