Jquery Dialog没有显示

时间:2016-09-09 14:02:30

标签: javascript jquery dialog

我想生成一个从用户那里获取密码的对话框,这里有点我的代码。

<html>
<head>
<script type="text/javascript" src="jquery.min.js"></script>
<link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>

<body>
<input type='button' id='btnDelete' name='btnDelete' value='Delete' onclick='deleteRecord(".$row['ID'].")'/>
<div id="delete-dialog" style="display: none;" title="Delete Record">
    <label>Please type in admin's password:</label></br>
    <input type='password' size='25' id='inpAdminPassword'/>        
</div>
</body>
</html>

JS

function deleteRecord(ID){
var answer = confirm("Are you sure you want to delete this record?");
if(answer == true){
     $( "#delete-dialog" ).dialog( "open" );
    }
}

$(document).ready(function() {
$( "#delete-dialog" ).dialog({
    autoOpen: false,  
});

不知何故,对话框没有显示,必须缺少什么?

我也试过并包含了这段代码,但它仍然没有用。

$(document).ready(function() {
$( "#delete-dialog" ).dialog({
    autoOpen: false,  
});
$("#delete-dialog").dialog({
    modal: true,
    autoOpen: false,
    height: 255,
    width: 300,
    buttons: {
        "Delete": function() {
            var password = document.getElementById('sessionPW').value;
            var adminpw = document.getElementById('inpAdminPassword').value;
            alert(password);
            if(password == adminpw){
                window.location = "deleteThreat.php?threatID="+ID;
            }
        },
        Cancel: function() {
            $( this ).dialog( "close" );
            }
        }
    });
});

1 个答案:

答案 0 :(得分:0)

我正在尝试您的第一个解决方案,并使这样的确认对我有用:

JS:

buttonAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                num1 = Float.parseFloat(txtView.getText().toString());
                txtView.setText("");
            }
        });


buttonEqual.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                num2 = Float.parseFloat(txtView.getText().toString());
                sum = num1 + num2;
                txtView.setText(Float.toString(sum));
            }
        });

html:

    $("#delete-dialog").dialog({
        autoOpen: false,
    });

    $("#open").click(function () {

        if (confirm("are you sure?")) {
            $("#delete-dialog").dialog("open");
        }


    });