【发布时间】:2017-01-06 18:50:52
【问题描述】:
我有两个 JSP 页面,第一个页面有这样的链接:
<a id="page-help" href="#"
onclick="'referToDamageAssessor.do?method=showInsurantInf
&insurantId='+<%=temp.getPolicy().getLegalInsurant().getLegalInsurantId()%>;">
<%=temp.getPolicy().getLegalInsurant().getFirmName()%>
</a>
第二页显示来自带有 JSP scriptlet 标记的会话的操作数据。当用户单击链接时,我想在 jQuery 对话框中显示数据。我写了这段代码:
第一个 JSP 页面:
<a id="page-help" href="#"
onclick="'referToDamageAssessor.do?method=showInsurantInf&insurantId='+
<%=temp.getPolicy().getLegalInsurant().getLegalInsurantId()%>;">
<%=temp.getPolicy().getLegalInsurant().getFirmName()%>
</a>
这是我的 jQuery 对话框:
$(document).ready(function() {
$('#page-help').each(function() {
var $link = $(this);
var $dialog = $('<div></div>').load($link.attr('href'))
.dialog({
autoOpen: false,
show: "fade",
hide: "fade",
modal: true,
title: $link.attr('title'),
width: 500,
height: 300
});
$link.click(function() {
$dialog.dialog('open');
return false;
});
});
});
导入 jquery1.9.1.js、jquery-ui.js、jquery-ui.css
jQuery 对话框打开但为空。
【问题讨论】:
-
为什么要将 url 值分配给 onClick?它将接受一个函数(处理程序)作为值。