Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

sweetalert2

$ npm install sweetalert2
Comment

sweetalert 2 documentation

Swal.fire({
  title: 'Error!',
  text: 'Do you want to continue',
  icon: 'error',
  confirmButtonText: 'Cool'
})
Comment

sweetalert2

Swal.fire(
  'Data Add Successfully!',
  'You clicked the button!',
  'success'
)
Comment

sweetalert2

npm install sweetalert2 --save
Comment

sweetalert2

Swal.fire(
  'Good job!',
  'You clicked the button!',
  'failed'
)
Comment

sweet alert 2

npm install sweetalert2

// ES6 Modules or TypeScript
import Swal from 'sweetalert2'

// CommonJS
const Swal = require('sweetalert2')

const Toast = Swal.mixin({
  toast: true,
  position: 'top-end',
  showConfirmButton: false,
  timer: 3000,
  timerProgressBar: true,
  didOpen: (toast) => {
    toast.addEventListener('mouseenter', Swal.stopTimer)
    toast.addEventListener('mouseleave', Swal.resumeTimer)
  }
})



Use 
Toast.fire({
  icon: 'success',
  title: 'Signed in successfully'
})
Comment

sweet alert 2

npm install sweetalert2

// ES6 Modules or TypeScript
import Swal from 'sweetalert2'

// CommonJS
const Swal = require('sweetalert2')

const Toast = Swal.mixin({
  toast: true,
  position: 'top-end',
  showConfirmButton: false,
  timer: 3000,
  timerProgressBar: true,
  didOpen: (toast) => {
    toast.addEventListener('mouseenter', Swal.stopTimer)
    toast.addEventListener('mouseleave', Swal.resumeTimer)
  }
})



Use 
Toast.fire({
  icon: 'success',
  title: 'Signed in successfully'
})
Comment

sweetalert2

Swal.fire({
  title: '<strong>HTML <u>example</u></strong>',
  icon: 'info',
  html:
    'You ccccc can use <b>bold text</b>, ' +
    '<a href="//sweetalert2.github.io">links</a> ' +
    'and other HTML tags',
  showCloseButton: true,
  showCancelButton: true,
  focusConfirm: false,
  confirmButtonText:
    '<i class="fa fa-thumbs-up"></i> Great!',
  confirmButtonAriaLabel: 'Thumbs up, great!',
  cancelButtonText:
    '<i class="fa fa-thumbs-down"></i>',
  cancelButtonAriaLabel: 'Thumbs down'
})
Comment

sweetalert2

const Toast = Swal.mixin({
  toast: true,
  position: 'top-end',
  showConfirmButton: false,
  timer: 3000,
  timerProgressBar: true,
  didOpen: (toast) => {
    toast.addEventListener('mouseenter', Swal.stopTimer)
    toast.addEventListener('mouseleave', Swal.resumeTimer)
  }
})

Toast.fire({
  icon: 'success',
  title: 'Signed in successfully'
})
Comment

sweet alert 2

let timerInterval
Swal.fire({
  title: 'Auto close alert!',
  html: 'I will close in <b></b> milliseconds.',
  timer: 2000,
  timerProgressBar: true,
  didOpen: () => {
    Swal.showLoading()
    const b = Swal.getHtmlContainer().querySelector('b')
    timerInterval = setInterval(() => {
      b.textContent = Swal.getTimerLeft()
    }, 100)
  },
  willClose: () => {
    clearInterval(timerInterval)
  }
}).then((result) => {
  /* Read more about handling dismissals below */
  if (result.dismiss === Swal.DismissReason.timer) {
    console.log('I was closed by the timer')
  }
})
Comment

sweetalert2

// reactjs codeto browse and upload an image from your device  
const addImage =async() => {

    const { value: file } = await Swal.fire({
      title: 'Select image',
      input: 'file',
      inputAttributes: {
        'accept': 'image/*',
        'aria-label': 'Upload your profile picture'
      }
    })
    
    if (file) {
      const reader = new FileReader()
      reader.onload = (e) => {
        Swal.fire({
          title: 'Your uploaded picture',
          imageUrl: e.target.result,
          imageAlt: 'The uploaded picture'
        }
        
        )
        console.log(e.target.result);
      }
     
      reader.readAsDataURL(file)
    }
    
Comment

sweetalert2

Best alert library in javascript for me
:)
Comment

sweetalert2

const { value: email } = await Swal.fire({  title: 'Input email address',  input: 'email',  inputLabel: 'Your email address',  inputPlaceholder: 'Enter your email address'})if (email) {  Swal.fire(`Entered email: ${email}`)}
Comment

sweet alert 2

 // sweet alert 2
// exapmle 1
 <script>
            let button = $('.button')
            button.on('click', function() {
                let form = $(this).next('form');
                const swalWithBootstrapButtons = Swal.mixin({
                    customClass: {
                        confirmButton: 'btn btn-success',
                        cancelButton: 'btn btn-danger'
                    },
                    buttonsStyling: false
                })

                swalWithBootstrapButtons.fire({
                    title: '<h2 style="color:#545454">Are you sure?</h2>',
                    text: "You won't be able to revert this!",
                    icon: 'warning',
                    showCancelButton: true,
                    confirmButtonText: 'Yes, delete it!',
                    cancelButtonText: 'No, cancel!',
                    reverseButtons: true
                }).then((result) => {
                    if (result.isConfirmed) {
                        swalWithBootstrapButtons.fire(
                            'Deleted!',
                            'Your file has been deleted.',
                            'success'
                        )
                        form.submit()
                    } else if (
                        /* Read more about handling dismissals below */
                        result.dismiss === Swal.DismissReason.cancel
                    ) {
                        swalWithBootstrapButtons.fire(
                            'Cancelled',
                            'Your imaginary file is safe :)',
                            'error'
                        )
                    }
                })
            })
        </script>
// example 2

 <script>
            let button = $('.button')
            button.click(function() {
                let form = $(this).next('form');
                Swal.fire({
                    title: 'Are you sure?',
                    text: "You won't be able to revert this!",
                    icon: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: 'Yes, delete it!'
                }).then((result) => {
                    if (result.isConfirmed) {
                        Swal.fire(
                            'Deleted!',
                            'Your file has been deleted.',
                            'success'
                        )
                        form.submit();
                    }
                })
            })
        </script>
        
Comment

PREVIOUS NEXT
Code Example
Typescript :: array in typescript 
Typescript :: remove elements from array that has same value from other array 
Typescript :: ordenar por fecha arreglo de objetos typescript 
Typescript :: use sample weights fit model multiclass 
Typescript :: path para imports firebase firestore 
Typescript :: conda tsinghua 
Typescript :: salesforce lwc data binding for multiple inputs values 
Typescript :: mongoose model enum 
Typescript :: push in typescript 
Typescript :: ng2-dnd not working with angular11 
Typescript :: does any event get triggered when checked value changes programatically? 
Typescript :: module.exports mongodb connection 
Typescript :: convert c# class to typescript 
Typescript :: O arquivo yarn.ps1 não pode ser carregado porque a execução de scripts foi desabilitada neste sistema 
Typescript :: chakra ui menu open on hover 
Typescript :: type assertions in typescript 
Typescript :: Start Angular App In Localhost 
Typescript :: Interface with custom property name types 
Typescript :: git merge all previous commits on a branch 
Typescript :: cubic beziere curve function 
Typescript :: how to pring events in pygame 
Typescript :: typescript delete value from map 
Typescript :: type to string typescript 
Typescript :: typescript to c# converter 
Typescript :: using method parameters in a guard nestjs 
Typescript :: increment elements in array typescript 
Typescript :: Building a maven EAR project and specifying the configuration of which projects to include, what is the element in the plugin configuration that contains Enterprise Java Bean Projects: 
Typescript :: Carbohydrates and fats both 
Typescript :: mui icons slow compile time 
Typescript :: Which Protect Presentation option protects a presentation from accidental changes: 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =