t4t5 / sweetalert

A beautiful replacement for JavaScript's "alert"
https://sweetalert.js.org
MIT License
22.39k stars 2.84k forks source link

close alert onclick on div #859

Open sombek opened 5 years ago

sombek commented 5 years ago

Hello

I need to close when click on div the alert and go to then function

screen shot 2018-09-17 at 10 43 34 am

I am creating the elements using jquery, the issue is when it closes the alert the actionValue parameter is null. Although I am setting the action value on click. I debug it by console.log(swal.getState()) it shows the correct data but when it reaches to then function it prints null.

$container = $("<div></div>");
for (const blockType of BlocksTypes)
    $container.append("<div class=\"type clickable\" onclick=\"swal.setActionValue($(this).text()); swal.close(); \">" + blockType + "</div>")
swal({
    title: 'Select block type:',
    content: $container[0],
    buttons: false
}).then((actionValue) => {
    console.log(actionValue)
})

you helps are appreciated 😺