2016-05-20 9 views
1

Ich benutze Sweet Alert-Plugin, um eine Schaltfläche zu erstellen und erstellen Sie ein Popup, um etwas zu löschen Ich möchte Textfeld deaktivieren, wenn der Löschvorgang ausgeführt wird, und ich weiß nicht wie Tue jemand mich?Deaktivieren Eingabe Textfeld in Sweet Alarm bei Verwendung showLoaderOnConfirm

jQuery("#vbb_btn_delete_post").on("click", function(e) { 
 
     swal({ 
 
      title: "Lý do xóa bài", 
 
      type: "input", 
 
      showCancelButton: true, 
 
      closeOnConfirm: false, 
 
      animation: "slide-from-top", 
 
      inputPlaceholder: "Write something", 
 
      showLoaderOnConfirm: true, 
 
      customClass: "mySwall" 
 
     },  
 
     function(inputValue){ 
 
      if (inputValue === false) return false; 
 
      if (inputValue === "") { 
 
       swal.showInputError("Bạn cần nhập lý do"); return false; 
 
      } 
 
      $('.mySwall').find(':text').prop('disabled', true); //it not working ???   
 
      jQuery.ajax({ 
 
       url: "http://staging.webtretho.vn/forum/editpost.php?do=deletepost&p={vb:raw postinfo.postid}", 
 
       type: "POST", 
 
       data: { 
 
        "dodelete": "1", 
 
        "deletepost": "delete", 
 
        "reason": inputValue, 
 
        "securitytoken": "{vb:raw bbuserinfo.securitytoken}", 
 
        "p": {vb:raw postinfo.postid}, 
 
        "url": "{vb:raw url}", 
 
        "do": "deletepost", 
 
        "posid": {vb:raw postinfo.postid}, 
 
        "forumid": {vb:raw $GLOBALS.forumid} 
 
       }, 
 
       dataType: "html", 
 
       success: function() { 
 
        //console.log(data); 
 
        swal("Done!","It was succesfully deleted!","success"); 
 
        window.location="http://staging.webtretho.vn/forum/f"+{vb:raw $GLOBALS.forumid}; 
 
       } 
 
      }); 
 
     //swal("Nice!", "You wrote: " + inputValue, "success"); 
 
     }) 
 
});

Antwort

1

Textbox Verwendung zu deaktivieren:

$("input").prop('disabled', true); 
$("input").prop('disabled', false); 
1

Wenn Sie die Eingangs Textbox im SweetAlert deaktivieren möchten, bevor Sie die Ajax-Aufruf auszuführen:

$(function() { 
 
    $('#btn').on('click', function (e) { 
 
    //$(this).prop('disabled', true); 
 
    swal({ 
 
     title: "Ajax request example", 
 
     text: "Submit to run ajax request", 
 
     type: "input", 
 
     inputPlaceholder: "Write something", 
 
     showCancelButton: true, 
 
     closeOnConfirm: false, 
 
     showLoaderOnConfirm: true, 
 
     customClass: "mySwal" 
 
    }, function (inputValue) { 
 
     if (inputValue === "") { 
 
     swal.showInputError("You need to write something!"); 
 
     return false 
 
     } 
 
     $('.mySwal').find(':text').prop('disabled', true); 
 
     setTimeout(function() { 
 
     swal("Ajax request finished!"); 
 
     }, 5000); 
 
    }); 
 
    }); 
 
});
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script> 
 
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css"> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script> 
 

 
<button id="btn">Click me To delete</button>

+0

ich benutze jquery ajax, um einen post in vbulletin 4 zu löschen, der code oben funktioniert nicht ich werde meinen code wieder zeigen sie können den flusscode sehen, den ich gemacht habe! Vielen Dank, :) – anthonydoan

+1

Vielen Dank für die Lösung, k Ich weiß nicht, warum die Stimmen in dieser Frage negativ waren. Btw danke fürs aushelfen für die Leute das Thema in Zukunft genauso wie ich. – Khateeb321

Verwandte Themen