JQuery подтвердить плагин не работает

0

Я пытаюсь использовать jquery-плагин, используя jquery1.8.3. но обработчик событий (предупреждения) не работает ни для одной из кнопок.

    <!DOCTYPE html>
<html>
<body>

<button class="confirm" type="button">Delete the comment</button>


<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="jquery.confirm.js"></script>
<script type="text/javascript">

$(document).ready(function(){
$(".confirm").confirm({
    text: "Are you sure you want to delete that comment?",
    title: "Confirmation required",
    confirm: function(button) {
        alert("foo")
    },
    cancel: function(button) {
        alert("bar")
    },
    confirmButton: "Yes I am",
    cancelButton: "No",
    post: true
});
});
</script>
</body>
</html>

любой ключ?

  • 0
    Если вы посмотрите на требования, он говорит, Bootstrap 3 для модальных
  • 0
    обновлен код для bootstrap3, но есть ошибка в файле verify.js в modal.modal ('show');
Показать ещё 2 комментария
Теги:
jquery-plugins
confirm

2 ответа

0

Я вижу, вы пытаетесь использовать настраиваемый плагин подтверждения, где вам нужно скачать jquery confirm plug in и bootstrap. Вместо этого я использовал код, предоставленный jquery для создания подключаемого модуля в моем проекте php, который работает отлично. См. Код ниже. он отлично работает для меня. проверьте эту ссылку для получения дополнительной информации. https://jqueryui.com/dialog/#modal-confirmation

    <!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
<script type="text/javascript">

$(document).ready(function(){
$("#submitbutton").click(function() {
$( "#dialog-confirm" ).dialog( "open" );
      });
 $("#dialog-confirm").dialog({
      autoOpen: false,
      height: 400,
      width: 400,
      resizable: false,
      modal: true,
      buttons: {
        "Confirm": function() {
           alert("Clicked Confirm");
           $( this ).dialog( "close" );

        },
        Cancel: function() {
          alert("Clicked Cancel");
          $( this ).dialog( "close" );
        }
      }
    });
});


</script>
</head>
<body>
<input type="button" id="submitbutton" value="Submit"/>
<div id="dialog-confirm">
<p>Are you sure?</p>
</div>
</body>
</html>
0

Попробуйте вот так:

 $(document).ready(function(){
   $(".confirm").click(function(){
     $.confirm({
     'message': "Are you sure you want to delete that comment?",
     'title': "Confirmation required",

     'buttons': {
            'Yes': {

                'action': function(){
                   alert();
                   }
                 },
            'No': {

                'action': function(){
                   alert()
                }
              }
           });

        });

    });

Я не понимаю, почему вы помещаете кнопку в качестве параметра.

  • 0
    не повезло. Хотя здесь можно использовать кнопку // modal.find (". Подтвердить"). Click (function () {settings.confirm (settings.button);});

Ещё вопросы

Сообщество Overcoder
Наверх
Меню