Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(modal): data-backdrop="static", data-keyboard="false" not work #568

Closed
hongbo-miao opened this issue Jun 2, 2016 · 12 comments
Closed

Comments

@hongbo-miao
Copy link
Contributor

hongbo-miao commented Jun 2, 2016

In Bootstrap 4, we can disable click outside of bootstrap model area to close modal by adding data-backdrop="static".
And data-keyboard="false" to prevent close on ESC button.

Like this:

<button class="btn btn-primary" data-toggle="modal" data-target=".bd-example-modal-lg">Large modal2</button>
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      ...
    </div>
  </div>
</div>

However, either of them do not work on ng2-bootstrap modal.

<button class="btn btn-primary" (click)="lgModal.show()">Large modal</button>
<div bsModal #lgModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" (click)="lgModal.hide()" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title">Large modal</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
    </div>
  </div>
</div>
@hongbo-miao hongbo-miao changed the title data-backdrop="static" and data-keyboard="false" do not work on modal bug(modal): data-backdrop="static" and data-keyboard="false" do not work Jun 2, 2016
@hongbo-miao hongbo-miao changed the title bug(modal): data-backdrop="static" and data-keyboard="false" do not work bug(modal): data-backdrop="static", data-keyboard="false" not work Jun 2, 2016
@valorkin
Copy link
Member

valorkin commented Jun 2, 2016

It is OK, it should work via option

@hongbo-miao
Copy link
Contributor Author

Nice! Just saw API

@hongbo-miao
Copy link
Contributor Author

hongbo-miao commented Jun 3, 2016

@valorkin I tried these two, but neither of them works.

<div bsModal #lgModal="bs-modal" class="modal fade" [config]="{backdrop: false, keyboard: false}" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">

<div bsModal #lgModal="bs-modal" class="modal fade" config="{backdrop: false, keyboard: false}" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">

@hongbo-miao hongbo-miao reopened this Jun 3, 2016
@hongbo-miao
Copy link
Contributor Author

hongbo-miao commented Jun 4, 2016

Since #574 is similar, so I close this issue.

@calvinKG
Copy link

Hi Guys,

How those this fix work ?

@ctrl-brk
Copy link

ctrl-brk commented Oct 3, 2016

[config]="{backdrop: 'static'}" works for me in 1.1.5

@AitanQamet
Copy link

$('#myModal').modal({backdrop: 'static', keyboard: false});
try this , it works in my project.

@ghost
Copy link

ghost commented Feb 13, 2018

@component({
selector: 'ngx-app',
templateUrl: 'app.component.html'
})
export class AppComponent {
config = {
animated: true,
keyboard: true,
backdrop: false,
ignoreBackdropClick: true
};
bsModalRef: BsModalRef;
constructor(private modalService: BsModalService) {}

openClientModal() {
this.bsModalRef = this.modalService.show(ClientModalComponent, this.config);
console.log(this.bsModalRef);
this.bsModalRef.content.title = 'New Client';
}

}

works for me

@asabarimanigandan
Copy link

Could you pls share me your source code ?

@carlitospc
Copy link

carlitospc commented Nov 1, 2018

@hongbo-miao la respuesta es de la siguiente forma:

[config]="{ignoreBackdropClick: true, keyboard: false}"
En el html, es decir:

<div bsModal #formularioModal="bs-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="formularioModalLabel" aria-hidden="false" [config]="{ignoreBackdropClick: true, keyboard: false}">
  <div class="modal-dialog modal-lg" role="document">

@shivamdawas
Copy link

it works @hongbo-miao
add this [config]="{ignoreBackdropClick: true, keyboard: false}"

@fabiomarcos70
Copy link

it works after a lot of others. Tks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants