Using Alert BS5

I have a project with Alert. It has settings: dismissable: true;

I set Alert to hidden = true.
I show it with:

Button1.onclick=function(){
Alert1.show();
}

Is it correct that if I click anywhere in Alert, it disappears? Shouldn’t it only disappear when I click “X”?

Why is this important to me. If there is an “X” sign, it should close the alert because if someone wants to click and select the message to copy it, the alert will disappear, I don’t want that

If I wanted the alert to disappear after clicking anywhere, I would do:

Alert1.onclick=function(){
Alert1.hide();
}

I think that closing the alert with dismissable: true; should happen after clicking “X”

A simple example:
Alert.appstudio.zip (9.0 KB)

In your code, you have this:

  Alert1.onclick=function(){
  Alert1.hide();
}

which dismisses the Alert no matter where you click on it. That is also the default behavior, so it will happen even if you don’t have it.

To ignore clicks, you can do this:

function Main() {
  Alert1.onclick = null;
}

But now you have another problem: the close button on the Alert won’t actually do anything. In Bootstrap, it’s an indication that clicking on the Alert will dismiss it, but it isn’t an actual button. You may need to display a separate Button control on top of the Alert.

Sorry, funny mistake, I’m ashamed :slight_smile:
This:

Alert1.onclick=function(){
Alert1.hide();
}

remained from an earlier version where I used: dismissable: false;

Now I’ve sent a project that doesn’t have this function anymore, but Alert also closes. Is this how BS5 works?

I found solutions:

function Main() {
Alert1.onclick = null;
Alert1.onclick = Alert1onclick;
}

function Alert1onclick(e){
if (e.target.type == 'button') Alert1.hide();
}

Do you think this solution is good?

Yes, that looks like it could work.