提交表单确认提醒sweet_alert.min.js

时间:2017-11-16 03:31:42

标签: jquery sweetalert

我正在使用库js / sweet_alert.min.js,我需要在确认警报时发送表单而我无法执行this.form.submit();无法正常工作

JS:

$('#sweet_warning').on('click', function() {        
    e.preventDefault();
    var form = $(this).parents('form');        
    swal({
        title: "¿Está seguro que desea cargar esta mesa?",
        text: "",
        type: "warning",
        showCancelButton: true,
        cancelButtonText: "Cancelar",
        confirmButtonColor: "#FF7043",
        confirmButtonText: "Aceptar"            
    },
    function(isConfirm){        
         form.submit();     
    }
    );
});

HTML:

<form method="post" action=""> 
  <button type="button" name="submiti" id="sweet_warning" class="btn bg-warning">
    Ingresar <i class="icon-circle-right2 position-right"></i>
  </button> 
</form>

1 个答案:

答案 0 :(得分:0)

忘记以前的版本并在最新版本 private VideoView videoView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main3); findViewById(R.id.video_view).setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Toast.makeText(getApplicationContext(),"edit",Toast.LENGTH_SHORT).show(); if (videoView.isPlaying()) { videoView.pause(); } videoView.setVideoURI(Uri.parse("https://archive.org/download/Popeye_forPresident/Popeye_forPresident_512kb.mp4")); videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { videoView.start(); } }); } }); } @Override public void onPrepared(MediaPlayer mp) { //Starts the video playback as soon as it is ready videoView.start(); } 中使用此代码段:

&#13;
&#13;
version 2
&#13;
$('#sweet_warning').on('click', function(e) {
  e.preventDefault();
  swal({
    title: "¿Está seguro que desea cargar esta mesa?",
    text: "",
    buttons: {
      text: "Aceptar!",
      cancel: "Cancelar!"
    }
  }).then(
    function(isConfirm) {
      alert(isConfirm)
      if(isConfirm){
        $('#your_form').submit();
      }
    }
  );
});
&#13;
&#13;
&#13;