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

issue with this.buttons.save.disable()

Open deepaksurthi opened this issue 5 years ago • 0 comments

jquery-confirm version: v3.3.2

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

Current behavior: I have a ajax call inside action: function(){}. i am checking $.when(ajaxcall){ // inside here if ajax response returns a valid output, then i am trying to disable button using this.buttons.save.disable(); } Example: buttons: { save: { action: function(){ $.when(ajaxcall).done(function(result){ if(result != 'Error') { this.buttons.save.disable(); // not working this.$$save.prop('disabled',true) // not working (either of these) }
} if i call above functions here which is working fine.
} } cancel:{} }

Expected behavior:

i am excepting them to work irrespective of where i call or am i missing something. please tell me

Steps to reproduce:

Related code:

$("#add-new").on('click', function(){
		$.confirm({
			title: '<label>New TP_PRODUCT_INFO</label>',
			content: 'url:${pageContext.request.contextPath}/UserMaint/new-product-div',
			boxWidth: '80%',
			useBootstrap: false,
			buttons: {
				save: {
					text: 'Save',
					btnClass: 'btn-info',
					action: function(){
						valid = true;
						var prodIdNbr = this.$content.find('input[name=PRODUCT_ID_NBR]');
						var coIdCd = this.$content.find('select[name=CO_ID_CD]');
						var grpIdNbr = this.$content.find('input[name=GRP_ID_NBR]');
						var divIdNbr = this.$content.find('input[name=DIV_ID_NBR]');
						var tpIdNbr = this.$content.find('input[name=TP_ID_NBR]');
					    valid = validateFieldEmpty(prodIdNbr, "PRODUCT_ID_NBR");
						if(valid) valid = validateFieldNumericOnly(prodIdNbr, "PRODUCT_ID_NBR");
						if(valid) valid = validateFieldEmpty(grpIdNbr, "GRP_ID_NBR");
						if(valid) valid = validateFieldEmpty(divIdNbr, "DIV_ID_NBR");
						if(valid) valid = validateFieldEmpty(tpIdNbr, "TP_ID_NBR");
						if(valid) valid = validateFieldNumericOnly(tpIdNbr, "TP_ID_NBR");
						if(valid) {
							$.when(validateDuplicate(prodIdNbr, coIdCd, grpIdNbr, divIdNbr, tpIdNbr)).done(function(result){
								if(result != 'Error') {
									valid = true;
									$("form").attr("action","${pageContext.request.contextPath}/UserMaint/save-product-div/");
									$("form").submit();
									this.buttons.save.disable();
									this.buttons.save.setText("Please wait...");
									this.buttons.cancel.hide();
								} else {
									valid = false;
									$.alert({
										title: 'Warning',
										content: "Duplicate Entry.",
										type: 'red',
									});
									return false;
								}
							})
						}
						return false;
						
					}
				},
				cancel: function(){
				}
			}
		});
	});

Other information:

deepaksurthi avatar Aug 07 '20 16:08 deepaksurthi