Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

sweetalert2

$ npm install sweetalert2
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

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

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

PREVIOUS NEXT
Code Example
Javascript :: erc20 token api 
Javascript :: Check If Object Contains A Function 
Javascript :: short-circuit evaluation javascript 
Javascript :: file upload with progress bar 
Javascript :: database for javascript 
Javascript :: map.set javascript 
Javascript :: what is bom in javascript 
Javascript :: how to download array of files from aws s3 using aws sdk in nodejs 
Javascript :: req.header express.js 
Javascript :: how to display a calender in react native 
Javascript :: disadvantages of array 
Javascript :: launch json 
Javascript :: javascript pipe async functions 
Javascript :: cross browser testing 
Javascript :: find last item in an array JS 
Javascript :: regular expression escape character 
Javascript :: react-datepicker 
Javascript :: check items in array javascript 
Javascript :: react hook from 
Javascript :: react-native-vector-icons 
Javascript :: sweetalret 
Javascript :: else in javascript 
Javascript :: use ref in component reactjs 
Javascript :: javascript block link action 
Javascript :: typeahead bootstrap 4 add multiple values 
Javascript :: get JSON information into html control with javascript 
Javascript :: working with binary and base64 data 
Javascript :: When an aqueous solution of AgNO3 is mixed with an aqueous solution of (NH4)2CrO4, a precipitation reaction occurs. For this reaction, a) Write the molecular equation. 
Javascript :: queryselect get type of elment class or id 
Javascript :: Expressions 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =