swal.disableConfirmButton() not working
See original GitHub issueI just noticed this does not work and throws a "ERROR TypeError: sweetalert2_1.default.disableConfirmButton is not a function"
To reproduce just create a new project with Angular CLI (I’m using version 1.6.6) and modify app.component.ts a bit:
import { Component } from '@angular/core';
import swal from 'sweetalert2';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
constructor() {
swal.disableConfirmButton();// <-- this doesn't work
swal("sfsdfdsfd");// <-- this works fine
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Disable Confirm Button conditionally in sweetalert
PS: In documentation I found swal.disableConfirmButton() method but while using the same Angular throws an error
Read more >Change button state using sweetalert2 : r/learnjavascript
I tried that approach but it is not working. ... showLoading() }) // in whatever function your element calls after loading Swal.
Read more >disable confirm button swal - Code Examples & Solutions For ...
disable button in swal popup ; 1. function DeleteConfirm(c){ ; 2. swal({ ; 3. title: "Want to delete this item?", ; 4. text:...
Read more >SweetAlert2 - Translider Demenagement
Disable the "Confirm"-button only. swal.showLoading() or swal.enableLoading(), Disable buttons and show loader. This is useful with AJAX requests. swal.
Read more >SweetAlert2 - MIT Muzaffarpur
}).then(function () { swal( 'Deleted!', 'Your file has been deleted. ... showConfirmButton, true, If set to false, a "Confirm"-button will not be shown....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, those DOM-related functions are created after the first modal is shown. They do not set a state on which the button state is based: these are imperative DOM manipulations.
That’s why I use thunks here (see comment): https://github.com/sweetalert2/ngx-sweetalert2/blob/master/src/swal-partial-targets.ts#L3 (by the way, you just gave me a wonderful feature idea, thanks 😄).
You first need to request a modal in order to use
disableConfirmButton()
. You can use theonOpen
hook to perform your call (onOpen
is called before the modal is shown, but when its DOM is already created, therefore you won’t see the button “blink”):JSFiddle demo.
@toverux @limonte It is possible to change the new
context
object to a class instance and move code into instance methods. In fact the only reason I didn’t do this in #969 was to avoid the huge code change that’s hard to review and can result in merge conflicts.