jquery对话框错误:预期的标识符,字符串或数字

时间:2012-07-04 12:03:06

标签: jquery dialog

我从jquery对话框中收到错误消息:

  

错误:预期的标识符,字符串或数字。

错误消息指向具有buttons: {声明的行。谁知道什么可能导致问题?

$(document).ready(function(){


var $dialog = $('<div></div>').html('<form id="myform" action=""><input type="checkbox" id="completeCheck" name="completeCheck" value="" />Completeness check<br /><input type="checkbox" name="viewUnofficial" value="Car" /> View unofficial status <br /><input type="checkbox" name="consist" value="" />Consistency<br /><input type="checkbox" name="otherData" value="" />Other checks<br /><input type="checkbox" name="keyCheck" value="" />Key check<br /><input type="checkbox" name="compareVersions" value="" />Compare versions<br /></form>').dialog({
    autoOpen: false,
    title: 'Select data check',
    buttons: {
        "Submit Form": function () {
            $('form#myform').submit();
        },
        "Cancel": function () {
            $(this).dialog("close");
        }
    }
});

});

1 个答案:

答案 0 :(得分:0)

代码的工作演示 http://jsfiddle.net/ta7QY/

随意玩这个演示; $('div')我还点击了一个链接来实例化对话框。其余代码如下。

这会有所帮助,:)

<强>码

$("#forgot").click(function(e){ 
    $dialog.dialog("open");
    e.preventDefault();
});


var $dialog = $('<div>')
    .html('<form id="myform" action=""><input type="checkbox" id="completeCheck" name="completeCheck" value="" />Completeness check<br /><input type="checkbox" name="viewUnofficial" value="Car" /> View unofficial status <br /><input type="checkbox" name="consist" value="" />Consistency<br /><input type="checkbox" name="otherData" value="" />Other checks<br /><input type="checkbox" name="keyCheck" value="" />Key check<br /><input type="checkbox" name="compareVersions" value="" />Compare versions<br /></form>')
    .dialog({
        autoOpen: false,
        title: 'Select data check',
                buttons: {   
          "Submit Form": function() {  $('form#myform').submit();},
          "Cancel": function() {$(this).dialog("close");}
        }
    });
​

<强>脚本

  <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/base/jquery-ui.css">

  <link rel="stylesheet" type="text/css" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css">

  <script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js"></script>