jquery-confirm icon indicating copy to clipboard operation
jquery-confirm copied to clipboard

showLoading spinner disappears immediately

Open salasfoor opened this issue 4 years ago • 0 comments

jquery-confirm version: v3.x.x

I'm submitting a ... (check one with "x") [ ] bug report [ ] feature request [x] support request

Current behavior:

When using the prompt confirmation method, after clicking on submit, showLoading's spinner appears for a split of a second and does not continue until Ajax returned response. Expected behavior:

The spinner should last until the response from Ajax is ready and returned. Steps to reproduce: Apply the code. Related code:

var jc = $.confirm({
		title: 'Form Title',
		type: 'blue',
		content: '' +
		'<form class="formName">' +
		'<div class="form-group">' +
		'<div>Message</div>' +
		'<div><textarea name="msg" id="msg" class="msg" rows="8" maxlength="280"></textarea></div>' +
		'</div>' +
		'</form>',
		buttons: {
			formSubmit: {
				text: 'Send',
				btnClass: 'btn-blue',
				action: function () {
					
					var msg = $("#msg").val();
					
					
					$.ajax({
        				url: 'process.php',
            			        type: 'POST', 
            	      	                dataType: "json",
      					encode: true,
      					cache: false,
            			       data: {'msg' : msg},	   				
    				       }).done(function (resp) {
    					
						  console.log(resp);
						  if (!resp.status) {

								$.alert({
									rtl: true,
									title: 'Result!',
									content: '<span style="color: red;">' + resp.url + '</span>',
									type: 'red',	
									buttons: {
										cancel: {
											text: 'Back',
										}
									}
								});      
  
						  } else {

								$.alert({
									rtl: true,
									title: 'Result!',
									content: resp.url,
									type: 'green',
									buttons: {
										cancel: {
											text: 'Back',
											action: function(){
					
											}},
			
									}
								});
  
						  }

						});
						
				}
			},
			cancel: {
				text: 'Back'
			},
		},

		onAction: function () {
		jc.showLoading();
		},
		onContentReady: function () {
			// bind to events
			var jc = this;
			
			this.$content.find('form').on('submit', function (e) {
				// if the user submits the form by pressing enter in the field.			
				e.preventDefault();
				jc.$$formSubmit.trigger('click'); // reference the button and click it
				
			});
			
		}
	});

Other information:

salasfoor avatar Aug 19 '21 01:08 salasfoor