How to make sweetalert popup can be draggable anywhere?

Hello, i have a problem, i want to make a sweetalert to be draggable in everywhere the window. But how could i do it ? Have tried with simple popup and it works simply. But how a bout sweetalert ? thanksss

Here’s my code .

swal({title:"Konfirmasi Batal KYC!",
					text:"Apakah Anda yakin membatalkan KYC?",
					input: 'select',
					inputOptions: {
				    '1': 'Data tidak sesuai',
				    '2': 'Data tidak lengkap',
				    '3': 'Data tidak jelas'
				    },
		 			type:"warning",
		 			showCancelButton:!0,
		 			confirmButtonColor:"#DD6B55",
		 			confirmButtonText:"Yes",
		 			cancelButtonText:"No",
		 			closeOnConfirm:!1,
		 			closeOnCancel:!1,
		 			confirmButtonColor:"#f60e0e"}, 	 			
		 			function(t){t?
		 				swal({
						  title: "",
						  text: "Keterangan",
						  type: "input",
						  showCancelButton: true,
						  closeOnConfirm: false,
						  animation: "slide-from-top",
						  inputPlaceholder: "Keterangan"
						},
						function(inputValue){
						  if (inputValue === false) return false;

						  if (inputValue === "") {
						    swal.showInputError("Keterangan belum diisi");
						    return false;
						  }else{
						  	S_notes = inputValue;
						  	cancelKYC(ewalletcode,S_notes);
						  }
						})

						:

		 				swal({title:"Batal",
		 						text:"Anda batal melakukan pembatalan KYC.)",
		 						type:"error",
		 						confirmButtonColor:"#f60e0e"})
		 				});

Hi @achmad_airjyp, well SweetAlert doesn’t support dragging by itself, and since it’s a modal (it creates an overlay that prevents you from accessing the content underneath), there would actually be little point in doing so… it would require some significant modifications at any rate, and such modifications might even break with future releases. So I’d suggest to simply use a library that better suits your requirements (if everything fails there’s always jQuery UI), or write your own solution.

2 Likes

I totally agree with what @m3g4p0p said, but I would go beyond that and say that if you think you need a draggable modal then you should rethink your design decisions that lead you to this point. There are usually better ways to accomplish what you need to do rather than create a draggable modal, which is almost always clunky and hardly ever actually useful to anyone.

2 Likes

Hi! thanks so much for the reply sir!

Thank you sir, anyway i have changed it to simple modal and draggable was work, but still i just wanna know maybe there something sweet alert can do for draggable. Thank you

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.