Диалоговое окно не появится - PullRequest
0 голосов
/ 05 апреля 2019

Я хочу показать диалоговое окно при нажатии кнопки, но оно работает неправильно.Это мой код:

<!DOCTYPE html>
<html lang="en">
<head>
<title>Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script
    src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
    
</script>
<script type="text/javascript"
    src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>
</head>
<body>

    <button id="myButton">click!</button>

    <div id="dialog" title="Dialog box">My content</div>

    <script type="text/javascript">
        $(document).ready(function() {
            $(function() {
                
                $("#dialog").dialog({
                    autoOpen: false,
                    modal: true
                });
                
                $("#myButton").on("click", function(e) {
                    e.preventDefault();
                    $("#dialog").dialog("open");
                });
                
            });
        });
    </script>
</body>
</html>

Вот что происходит после того, как я нажимаю кнопку.Текст, который должен находиться внутри диалогового окна, отображается как обычный текст, сопровождаемый кнопкой «Закрыть».

Image showing the problem

1 Ответ

0 голосов
/ 05 апреля 2019

Импорт таблицы стилей в <head> области. Это будет стиль, который будет выглядеть в примере https://jqueryui.com/dialog/#default

<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

Вы можете дополнительно стилизовать его, добавив

...
$("#dialog").dialog({



    classes: {
      "ui-dialog": "stylethisclass",        // style these classes in CSS
      "ui-dialog-titlebar": "alsotitlebar", 
      "ui-dialog-content": "alsobody"       
    },



    autoOpen: false,
    modal: true
});
...

вот как это работает во всех деталях: http://api.jqueryui.com/dialog/#option-classes

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...