Sweetalert: Make user can customize id of confirm/cancel button

Created on 30 Jul 2017  ·  4Comments  ·  Source: t4t5/sweetalert

I have an idea about make user can customize id of confirm/cancel button, which can make custom function easier.

Most helpful comment

This is workaround for someone who are looking for id
onOpen: function() { $('.swal2-confirm').attr('id','btnConfirm');$('.swal2-cancel').attr('id','btnCancel');}
use method onOpen + javascript or jquery to find element with unique class and add attribute id into it.

All 4 comments

IDs are unnecessary, but you can customize the style of the buttons by using the unique classes swal-button--confirm and swal-button--cancel in SweetAlert 2.0.

An ID is really helpful for UI automated testing. Anyone know how to set the ID of buttons on a sweet alert dialog?

This is workaround for someone who are looking for id
onOpen: function() { $('.swal2-confirm').attr('id','btnConfirm');$('.swal2-cancel').attr('id','btnCancel');}
use method onOpen + javascript or jquery to find element with unique class and add attribute id into it.

@zerazeon amazing thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

burakkilic picture burakkilic  ·  9Comments

daybaryour picture daybaryour  ·  13Comments

voviks21 picture voviks21  ·  9Comments

GabrielSt picture GabrielSt  ·  9Comments

fabianchoxD picture fabianchoxD  ·  16Comments