下面是我的JSF代码和相应的HTML代码,它将被转换为
<script type="text/javascript" src="/static-files/js/jquery.min.js"></script>
<script type="text/javascript" src="/static-files/js/functions.js"></script>
<script type="text/javascript" src="/static-files/scripts/jquery-1.6.2.js"></script>
<script type="text/javascript" src="/static-files/scripts/jquery-ui.min.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<ui:composition>
<div id="myForm" style="visibility:hidden">
<a4j:commandLink id="cmdLinkClose" value="No Thanks"></a4j:commandLink>
</div>
<script type="text/javascript">
/* <![CDATA[ */
$("a[id$='cmdLinkClose']").click(function() {
$('#dialog').dialog('close');
});
/* ]]> */
</script>
</ui:composition>
HTML code:
<a href="#" id="j_id3:cmdLinkClose" name="j_id3:cmdLinkClose"
onclick="A4J.AJAX.Submit('j_id3',event,{'similarityGroupingId':'j_id3:cmdLinkClose'
,'parameters':{'j_id3:cmdLinkClose':'j_id3:cmdLinkClose'} } );return false;">No Thanks</a>
当我点击“No Thanks”链接时,我在Java Script控制台中遇到异常。
Uncaught TypeError: Object #<Object> has no method 'dialog'
我的xhtml页面中还有以下代码,
<script type="text/javascript">
/* <![CDATA[ */
var $h=jQuery.noConflict();
function myFunction()
{
$h(document).ready(function() {
$h("#myForm").attr("style", "display:block");
$h("#myForm").dialog({
open: function(event, ui) {
jQuery('.ui-dialog-titlebar-close').removeClass("ui-dialog-titlebar-close").html('<span>Close</span>');
},
duration: 800,
height: 300,
minWidth: 300,
width: 300,
position: [490, 160],
zIndex: 99999999,
modal: true,
show: {
effect: 'puff',
duration: 400
},
hide: {
effect: 'puff',
duration: 400
}
});
});
}
myFunction();
/* ]]> */
</script>
谷歌搜索后我了解到这可能是因为没有导入相关的Jquery Java Script文件。但是,就我而言,我不确定我需要导入/删除哪个Java Script。
更新
我将jquery-ui.min.js
替换为jquery-1.9.1.min.js
。以下是我现在的错误,
答案 0 :(得分:1)
好像你已经包含了三次jQuery库:
<script type="text/javascript" src="/static-files/js/jquery.min.js"></script>
<script type="text/javascript" src="/static-files/scripts/jquery-1.6.2.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
您只需要包含一次并将其放在jQuery UI和其他jQuery文件
之前<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="/static-files/js/functions.js"></script>
<script type="text/javascript" src="/static-files/scripts/jquery-ui.min.js"></script>