0
Good night.
I have a button that when clicked, calls the function below:
$('#sa-success').click(function () {
swal({
title: 'Good job!',
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed lorem erat, tincidunt vitae ipsum et, pellentesque maximus enim. Mauris eleifend ex semper, lobortis purus sed, pharetra felis',
type: 'success',
buttonsStyling: false,
confirmButtonClass: 'btn btn-primary'
});
});
But I wanted this function to be executed if a certain condition occurred in my IF. Example:
if(teste == true){
$('#sa-success').click(function () {
swal({
title: 'Good job!',
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed lorem erat, tincidunt vitae ipsum et, pellentesque maximus enim. Mauris eleifend ex semper, lobortis purus sed, pharetra felis',
type: 'success',
buttonsStyling: false,
confirmButtonClass: 'btn btn-primary'
});
});
}
It is possible?
Why don’t you put the
if
within the eventclick
?– Woss
You want to activate the
click
in#sa-success
only if test is true is it? if yes, it works.– fernandoandrade
This function is not executed... it remains silent until the event occurs. The question has become a little pointless. Does as suggested, puts the if in.
– Sam
This, the function is not executed, but this way if it does not pass in the
if
it is not tied to the element. But, it does with theif
inside, it’s easier to understand.– fernandoandrade