2014-01-08 3 views
0

Я пытаюсь настроить подтверждение сообщения с помощью плагинов. У меня есть записи таблиц php, каждая из которых имеет кнопку удаления. Как я могу настроить всплывающее подтверждение, как в jquery-плагинах ниже?Custom confirm pop

<?php echo' 
<tr class="record"> 
    <td align="center"><a href="#" id="'.$row["counter"].'" class="delbutton"><img src="images/del.png"></a></td></tr>'; 
?> 
    <script> 
     $(function() { 
     $(".delbutton").click(function(){ 
     var element = $(this); 
     var del_id = element.attr("id"); 
     var info = 'id=' + del_id; 
     if(confirm("Are you want to continue ?")) 
        { 
     $.ajax({ 
      type: "GET", 
      url: "delete.php", 
      data: info, 
      success: function(){ 
      } 
     }); 
       $(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast") 
       .animate({ opacity: "hide" }, "slow"); 
     } 
     return false; 
     }); 
     }); 
    </script> 

Jquery плагины

<script> 
$(function() { 
$("#dialog-confirm").dialog({ 
resizable: false, 
height:140, 
modal: true, 
buttons: { 
"Delete all items": function() { 
$(this).dialog("close"); 
}, 
Cancel: function() { 
$(this).dialog("close"); 
} 
} 
}); 
}); 
</script> 
</head> 
<div id="dialog-confirm" title="Empty the recycle bin?"> 
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p> 
</div> 
+1

Проверить http://stackoverflow.com/questions/43955/changing-the-default-title-of-confirm-in -javascript внизу вы можете сделать это, не используя плагины, вы можете использовать тот же плагин на вашем php, если хотите –

ответ

0

Надеется, что это помогает:

<?php echo' 
    <tr class="record"> 
     <td align="center"><a href="#" id="'.$row["counter"].'" class="delbutton"><img src="images/del.png"></a></td></tr>'; 
    ?> 
    <script> 
     $(function() { 
     $(".delbutton").click(function(){ 
      var element = $(this); 
      var del_id = element.attr("id"); 
      var info = 'id=' + del_id; 
      $("#dialog-confirm").dialog({ 
        resizable: false, 
        height:140, 
        modal: true, 
        buttons: { 
        "Delete all items": function() {       
         $.ajax({ 
         type: "GET", 
         url: "delete.php", 
         data: info, 
         success: function(){ 
          $(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast").animate({ opacity: "hide" }, "slow"); 
         } 
         }); 
         $(this).dialog("close"); 
        }, 
        Cancel: function() { 
         $(this).dialog("close"); 
         return false; 
        } 
        } 
       }); // end Dialog   
      return false; 
     }); // end .delbtn 
    }); // end jquery load 
    </script> 
+0

Элемент удален, но анимация удаления записей теряется. – user3097736

+0

Вы можете попробовать следующее '$ (this) .parents (". Record "). FadeOut ('slow')' вместо '$ (this) .parents (". Record "). Animate ({backgroundColor:" # fbc7c7 "}," fast "). animate ({opacity:" hide "}," slow ");'. Надеюсь, что эта помощь – Anunay

0

Если вам нужна дополнительная помощь, просто спросите.

"Delete all items": function() { 
// insert your ajax here 
$(this).dialog("close"); 
}, 

Ссылка: .dialog()

+0

Я пробовал, но не работал – user3097736