I am using bootstrap, My scenario is as follows:
There is a button, on clicking button I am opening up a popup and in that popup there is a button that is again opening up a new popup. Now I am trying to disable outside click when my popups are open. However when first popup is open then I have already disabled the outside click, but when it is not happening for 2nd popup.
I have used these attributes on button:
<button type="button" name="delete" class="btnbmbm" data-toggle="modal" data-target="#delete-user-confirm" data-backdrop="static" data-keyboard="false">Delete Me </button>
And here is complete html file:
<div class="page account-page customer-info-page customer-delete-info">
<div class="page-body">
<div class="form-fields">
<input type="hidden" value="#ViewBag.CustomerId" id="customerId" />
<div class="del-section">
#await Component.InvokeAsync("TopicBlock", new { systemName = "DeleteInformation" })
</div>
<div class="buttons">
<button type="button" name="delete" class="btn btn-primary btn-search" data-toggle="modal" data-target="#delete-user-confirm" data-backdrop="static" data-keyboard="false">
#T("Plugins.Tmotions.GDPR.User.DeleteMe")
</button>
</div>
</div>
<div id="delete-user-confirm" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="delete-user-title">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">#T("Plugins.Tmotions.GDPR.User.DeleteConfirmation")</h4>
</div>
<div class="form-horizontal">
<div class="modal-body">
#T("Plugins.Tmotions.GDPR.User.DeleteWarning")
</div>
<div class="modal-footer">
<button type="button" name="delete" class="btn btn-primary btn-search" data-toggle="modal" id="delete-confirm" data-target="delete-user-done" data-backdrop="static" data-keyboard="false">
#T("Plugins.Tmotions.GDPR.User.DeleteYes")
</button>
<button type="button" class="btn btn-primary btn-search" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"> #T("Plugins.Tmotions.GDPR.User.DeleteNo")</span></button>
</div>
</div>
</div>
</div>
</div>
<div id="delete-user-done" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="delete-user-done-title">
<div class="modal-dialog">
<div class="modal-content">
#*<div class="modal-header">
<button type="button" class="close delete-ok"><span aria-hidden="true">×</span></button>
<h4 class="modal-title"></h4>
</div>*#
<div class="form-horizontal">
<div class="modal-body">
<p class="delete-user-notification"></p>
<p> </p>
<p> #T("Plugins.Tmotions.GDPR.User.DeleteUserNotification2")</p>
</div>
<div class="modal-footer">
#T("Plugins.Tmotions.GDPR.User.Ok")
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Your code is fine. Your second modal doesn't close when clicked outside. Check the snippet. All you are missing is the # on your data-target attribute on your button.
<button type="button" name="delete" class="btn btn-primary btn-search" data-toggle="modal" id="delete-confirm" data-target="#delete-user-done" data-backdrop="static" data-keyboard="false">
#T("Plugins.Tmotions.GDPR.User.DeleteYes")
</button>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="page account-page customer-info-page customer-delete-info">
<div class="page-body">
<div class="form-fields">
<input type="hidden" value="#ViewBag.CustomerId" id="customerId" />
<div class="del-section">
#await Component.InvokeAsync("TopicBlock", new { systemName = "DeleteInformation" })
</div>
<div class="buttons">
<button type="button" name="delete" class="btn btn-primary btn-search" data-toggle="modal" data-target="#delete-user-confirm" data-backdrop="static" data-keyboard="false">
#T("Plugins.Tmotions.GDPR.User.DeleteMe")
</button>
</div>
</div>
<div id="delete-user-confirm" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="delete-user-title">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">#T("Plugins.Tmotions.GDPR.User.DeleteConfirmation")</h4>
</div>
<div class="form-horizontal">
<div class="modal-body">
#T("Plugins.Tmotions.GDPR.User.DeleteWarning")
</div>
<div class="modal-footer">
<button type="button" name="delete" class="btn btn-primary btn-search" data-toggle="modal" id="delete-confirm" data-target="#delete-user-done" data-backdrop="static" data-keyboard="false">
#T("Plugins.Tmotions.GDPR.User.DeleteYes")
</button>
<button type="button" class="btn btn-primary btn-search" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"> #T("Plugins.Tmotions.GDPR.User.DeleteNo")</span></button>
</div>
</div>
</div>
</div>
</div>
<div id="delete-user-done" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="delete-user-done-title">
<div class="modal-dialog">
<div class="modal-content">
#*<div class="modal-header">
<button type="button" class="close delete-ok"><span aria-hidden="true">×</span></button>
<h4 class="modal-title"></h4>
</div>*#
<div class="form-horizontal">
<div class="modal-body">
<p class="delete-user-notification"></p>
<p> </p>
<p> #T("Plugins.Tmotions.GDPR.User.DeleteUserNotification2")</p>
</div>
<div class="modal-footer">
#T("Plugins.Tmotions.GDPR.User.Ok")
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
Related
I really need some help with my ligning of my div(next to my label there should be#EditorFor(model=>model.CourseName) not below. The issue is my#Razor is below not next to my label. Here is my label;
<div class="row">
<div class="col-xs-3">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Start New Course
</button>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Start New Course</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="form-group row"></div>
<label for="CourseName" class="col-sm-2 col-form-label">CourseName:</label>
<div class="col-sm-8">#Html.EditorFor(model => model.CourseName, new { htmlAttributes = new { #class = "form-control", autofocus = "autofocus", placeholder = "CourseName" } })
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary">Create Course</button>
</div>
</div>
</div>
</div>
</div>
You can use bootstrap classes to align it to the right.
Add ml-auto to the col-xs-3
or add justify-content-end to row:
In the example I have added ml-auto to the column.
<div class="row">
<div class="col-xs-3 ml-auto">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Start New Course
</button>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Start New Course</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="form-group row"></div>
<label for="CourseName" class="col-sm-2 col-form-label">CourseName:</label>
<div class="col-sm-8">#Html.EditorFor(model => model.CourseName, new { htmlAttributes = new { #class = "form-control", autofocus = "autofocus", placeholder = "CourseName" } })
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary">Create Course</button>
</div>
</div>
</div>
</div>
</div>
I have a "customers" component (parent component), and it is related with "customer-page" component (child component).
In parent component, there is a modal, calling child component. In child component there are two more models which work as if all of those three are in the same component.
But when i close the modal of child component, it also closes the parent component's modal.
How can i fix that?
Customers Component HTML (Parent component HTML):
<button type="button" class="btn btn-primary btn-sm" id="mymodal" data-toggle="modal" data-target="#myModal">Customer's Page</button>
<div class="container">
<div class="row">
<div class="modal fade bd-example-modal-xl" id="myModal" tabindex="-1" data-backdrop="static" role="dialog" aria-labelledby="myExtraLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel">customer info</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<app-customer-page [customer]="currentCustomer"></app-customer-page>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary">Save</button>
</div>
</div>
</div>
</div>
</div>
</div>
Customer-Page HTML (Child Component HTML):
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal-inner" title="Edit"><i class="far fa-edit"></i></button>
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target=".bd-example-modal-sm" title="Delete"><i class="far fa-trash-alt"></i></button>
<div class="container">
<div class="row">
<div class="modal fade bd-example-modal-lg" id="myModal-inner" tabindex="-1" data-backdrop="static" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel">Customer Info</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<app-add-order [order]="currentOrder"></app-add-order>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary">Save</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="modal fade bd-example-modal-sm" tabindex="-1" data-backdrop="static" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel">Attention</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>This operation cannot be undone. Are you sure?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger">Delete</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>
Customer Page Component HTML
data-toggle="modal"
Your modals are binded to same variable named modal. Use different name for each modal in data-toggle.
I have 2 different bootstrap modals on a single page I would like the 2 .modal-backdrop classes to behave differently. How do I achieve that?
Here is the sample code:
<!-- Cancel Modal -->
<div class="modal fade" id="cancelModal"
tabindex="-1" role="dialog" aria-labelledby="cancelModal"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="cancelModalLabel">Cancel Warning</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Are you sure you want to cancel the form?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-
dismiss="modal">Close</button>
<button type="button" class="btn btn-primary"
(click)="cancel()">Yes</button>
</div>
</div>
</div>
</div>
<!-- Submit Modal -->
<div class="modal fade" id="submitModal" tabindex="-1"
role="dialog" aria-labelledby="submitModal" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="submitModalLabel">Submit Warning</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Are you sure you want to submit and close the form?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" routerLink="/submission"
(click)="submitForm()">Yes</button>
</div>
</div>
</div>
</div>
I am trying to make 2 modals on one page, one for a sign in form, the other for a signup form. Below are the declarations
<div class="modal fade" id="signUpModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal fade" id="signInModal" tabindex="-1" role="dialog" aria-hidden="true">
And here are the links that show the modals:
<a class="nav-link" data-toggle="modal" data-target="#signUpModal">Sign Up</a>
<a class="nav-link" data-toggle="modal" data-target="#signInModal">Sign In</a>
When I click the link to #signUpModal it works fine, however when I click the link to #signInModal, nothing happens, no modal is shown. If i then click the link to #signUpModal, the #signInModal then shows stacked on top of the #signUpModal.
How do I get the 2nd modal to appear correctly?
Use code as below:
NOTE!
put attention that you don't set same id twice... id is uniqe and you can use it once in each page(for eample:id="exampleModalLabel" so in second model set id="exampleModalLabel2")
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalIn">
Sing in
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModalIn" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Sing in</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalOut">
Sign out
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModalOut" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel2">Sign out</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
use href="#idOfModal" when using with a , use data-target="#idOfModal" when using button
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<a class="nav-link" data-toggle="modal" href="#signupModal">Sign Up</a>
<a class="nav-link" data-toggle="modal" href="#signinModal">Sign In</a>
<div class="modal fade" id="signinModal" tabindex="-1" role="dialog" aria-labelledby="signinModelLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Sign In</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="signupModal" tabindex="-1" role="dialog" aria-labelledby="signupModelLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Sign Up</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
YMMV, but the only way I was able to get this to work was putting the id into the modal class attribute. (it was ignoring the id attribute for some reason)
So instead of
<div class="modal fade" id="sampleDataModal" tabindex="-1" role="dialog" aria-labelledby="sampleDataModalLabel" aria-hidden="true">
I had to use:
<div class="modal fade sampleDataModal" tabindex="-1" role="dialog" aria-labelledby="sampleDataModalLabel" aria-hidden="true">
<! Modal Pair>
<dl class="row">
<div class="col-lg-3">
<button type="button" class="btn btn-outline-success btn-block" data-toggle="modal"
data-target=".sampleDataModal">
View Some Stuff
</button>
<div class="modal fade sampleDataModal" tabindex="-1" role="dialog" aria-labelledby="sampleDataModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="sampleDataModalLabel">Sample Stuff</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
some stuff
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-3">
<button type="button" class="btn btn-outline-success btn-block" data-toggle="modal"
data-target=".otherModal">
View Other Stuff
</button>
<div class="modal fade otherModal" tabindex="-1" role="dialog" aria-labelledby="otherModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="otherModalLabel">Other Modal
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
other stuff
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</dl>
I want to know that, why dismiss button does not work when I'm using it with model. Please visit the below link and suggest me how it is possible ?
http://builderfunding.co.in/doylesweb/index.html
Here is the code -
`
<button type="button" class="btn btn-default btn-lg btn-block" data-toggle="modal" data-target="#myModal">My Booking</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<button type="button" class="btn btn-default btn-lg btn-block" data-toggle="modal" data-target="#myModal1">How it Works?</button>
<!-- Modal -->
<!-- Modal -->
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
`
Hi its because your css code model and modal-backdrop both codes having almost same z-index values
.modal {
z-index: 1050;
}
.modal-backdrop{
z-index:1040;
}
remove modal-backdrop z-index , it will work fine (Bootstrap.min.css)
[ http://builderfunding.co.in/doylesweb/index.html ]