我做了这个漂亮的小桌子:
testPage.cfm:
<html>
<head>
<title>Test Page</title>
<style>
.blue{
background:#66CCFF;
padding: 1px 20px;
}
.red{
background:red;
padding: 1px 20px;
}
.blank{
background:#FFF;
padding: 1px 20px;
}
</style>
</head>
<body>
<cfform>
<cfinput type="checkbox" name="filters" value="blue" checked="yes"> Blue
<br />
<br />
<cfinput type="checkbox" name="filters" value="red" checked="yes"> Red
</cfform>
<cfdiv id="content" bind="cfc:TestCFC.displayTable({filters})"></cfdiv>
</body>
</html>
TestCFC.cfc:
<cfcomponent>
<cfscript>
remote function displayTable(filters){
var html = "";
var data = ArrayNew(1);
data[1] = 1;
data[2] = 2;
data[3] = 3;
data[4] = 4;
html = html & "<table>";
for(row = 0; row < 4; row++){
html = html & "<tr>";
for(column = 0; column < 2; column++){
html = html & '<td class="' & getCSS(data[row + 1], filters) & '">' & data[row + 1] & '</td>';
}
html = html & "</tr>";
}
return html;
}
private function getCSS(value, filters){
if(isIn("blue", filters) and value LTE 2)
return "blue";
else if(isIn("red", filters) and value GTE 3)
return "red";
else
return "blank";
}
private function isIn(item, list){
var array = ListToArray(list);
for(ndx = 1; ndx LTE ArrayLen(array); ndx += 1)
if(array[ndx] EQ item)
return True;
return False;
}
</cfscript>
</cfcomponent>
这在FireFox中工作得很好,但在Internet Explorer中效果不太好(提示:要让它在IE中响应,你必须在屏幕上的某个地方单击另一个时间)
IE版本7.0.6002.18005 ColdFusion 9
答案 0 :(得分:3)
我找到了自己的答案。变化
<cfdiv id="content" bind="cfc:TestCFC.displayTable({filters})"></cfdiv>
到
<cfdiv id="content" bind="cfc:TestCFC.displayTable(filters={filters@click})"></cfdiv>
这是让我指向正确方向的post。