Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery UI对话框-使用javascript函数链接_Jquery_Jquery Ui Dialog - Fatal编程技术网

jQuery UI对话框-使用javascript函数链接

jQuery UI对话框-使用javascript函数链接,jquery,jquery-ui-dialog,Jquery,Jquery Ui Dialog,在jquery对话框中是否可以有一个调用javascript函数的链接?像这样的- var msg-dialog = $('#dialog-msg'); msg-dialog .html("Please click < a href='javascript:void(0)' onclick='javascript:reload();'>here</a> to reload."); msg-dialog('open'); function reload() {

在jquery对话框中是否可以有一个调用javascript函数的链接?像这样的-

var msg-dialog = $('#dialog-msg');
msg-dialog .html("Please click < a href='javascript:void(0)' onclick='javascript:reload();'>here</a> to reload.");
msg-dialog('open');

 function reload() {
      // do something.
      alert('test');
    }
var-msg-dialog=$('#dialog-msg');
msg dialog.html(“请单击此处重新加载”。);
消息对话框(“打开”);
函数重载(){
//做点什么。
警报(“测试”);
}

该链接在对话框中显示得很好,但单击该链接没有任何作用。我错过了什么?我还想关闭函数中的对话框。

假设您有适当的库,这将立即生效:

<html>
<head>
<link href="jqueryUI/css/ui-lightness/jquery-ui-1.8.19.custom.css" rel="stylesheet" type="text/css">
<script src="jquery-1.7.1.js"></script>
<script src="jqueryUI/js/jquery-ui-1.8.19.custom.min.js"></script>

<script type="text/javascript">
function doSomething() {
    $('#dialog').dialog('close');
}

$(document).ready(function() {
    $("#dialog").dialog();
    $("#dialog").html("<a href=\"#\" onclick=\"doSomething();\">Call doSomething() function!</a>");
});
</script>

</head>
<body>
<div id="dialog"></div>

</body>

</html>

函数doSomething(){
$('dialog')。dialog('close');
}
$(文档).ready(函数(){
$(“#dialog”).dialog();
$(“#dialog”).html(“”);
});

根据ECMAScript 5.1/Unicode 6.1,msg dialog
是无效变量

var msg_dialog = $('#dialog-msg');
msg_dialog .html("Please click <a href='javascript:void(0)' onclick='javascript:reload();'>here</a> to reload.");
msg_dialog.dialog(); // notice this
var msg_dialog=$('dialog msg');
msg_dialog.html(“请单击以重新加载”);
msg_dialog.dialog();//注意这一点
这里
a前面有一个空格,应该是


我明白你的意思。关于a前面的空格,我特意添加了空格,因为软件可以显示文本。如果没有空间,它实际上是在解析它。这个演示非常完美。我刚刚查看了Firebug的控制台窗口,它显示“未定义重新加载”。我认为它正在另一个位置寻找功能。但是函数就在那里,并且它的命名正确。如果我像
,它工作正常。将
函数reload(){…}
放在
head
标记中。我的应用程序实际上有一个.js文件。它在应用程序的母版页中引用。是否要我将.js文件中的函数移动到母版页的头标记?如果引用了该函数,则可以将其保留在js文件中,但应将其正确包含在母版页中。这是可行的,但当您动态设置内部文本(超链接)时,没有。您想在哪里设置内部文本?例如在
ready
函数中-
$(document).ready(function(){$(“#dialog”).html(“”)
我发现它找不到函数。我做了一个小编辑以反映您正在尝试执行的操作。所做的更改似乎很有效。成功了!我必须删除javascript标记,并逃避整个过程!非常感谢。