我目前有一个绑定到CFC的CFSELECT列表以获取数据列表。
这是我的CFSELECT
<cfselect name="descriptionDD4"
id="descriptionDD4"
value="description"
bind="cfc:cfcs.menudata.getData()"
bindonload="true" />
这是我的CFC
<!---First Slect Box --->
<cffunction name="getData" access="remote" returntype="query">
<cfoutput>
<!--- Function to get data from datasource --->
<cfquery name="data" datasource="#datasource#">
select description
from service_descriptions
order by description
</cfquery>
</cfoutput>
<!--- Return results --->
<cfreturn data>
</cffunction>
我想做的是在这个列表的顶部添加一个静态选项,它是一个超链接。但是我发现,如果我使用bind命令,我不能添加任何选项到我的列表,因为它会抛出CF错误。
是否有任何方法可以保持我当前的配置,但在此列表中添加超链接选项?
我想到了一种方法,通过使用这个脚本:
<!---Script to pop modal if "add New" is selected --->
<script>
$(function(){
// bind change event to select
$('##descriptionDD3').on('change', function () {
var option = $( "##descriptionDD3 option:selected" ).text(); // get selected value
if (option == 'ADD NEW') { // require a URL
$('##addDescriptionsLink').trigger('click'); // redirect
}
return false;
});
});
</script>
我的脚本将检查选项"ADD NEW"是否被选中,然后它将启动我在我的页面上定义的链接。