我伊特諾運行一個jQuery/ColdFusion的問題,請通過下列文件證明:jQuery multiple .load()剝離出ColdFusion Ajax控件?
cflayout.cfm:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<cflayout name="tabtest" type="tab">
<cflayoutarea name="tab1" title="tab1" >
<span>This is tab 1</span>
</cflayoutarea>
<cflayoutarea name="tab2" title="tab2" >
<span>This is tab 2</span>
</cflayoutarea>
</cflayout>
</html>
cfcontent.cfm:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<cfajaximport tags="cfform,cflayout-tab">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--commenting out the jquery loader is for when loading via cftest.html
When run on its own, uncomments it-->
<!--<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>-->
<script type="text/javascript">
$(document).ready(function(){
$("#fcontent").load("cflayout.cfm");
});
</script>
fcontent:
<div id="fcontent">
</div>
</html>
cftest.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>CFLayout Test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#fdiv").load("cfcontent.cfm");
});
</script>
</head>
<body>
<div id="fdiv">
</div>
</body>
</html>
在現實生活中,cfcontent.cfm文件充當將流程重定向到其他頁面的分類頁面。
現在cflayout.cfm本身運行良好,就像cfcontent.cfm一樣。但試圖加載cftest.html和選項卡控件消失,好像通過多次使用jquery .load()已經「剝離」了控件。
有沒有人遇到過這個?這是一個已知的問題?由於實際的.html在這種情況下是繼承的,我不能用.cfm文件替換它,而使用cfinclude。
關於我應該如何重新構建我的方法的任何建議?
您可能需要使用cfajaximport父頁面上,確保爲您cflayout腳本被加載。 – Henry 2010-11-26 20:12:17