Thank you for reading this question.
Iam opening the modal from typescript code after some API success reponse.
It is binding normally after taking more time eventhough if iam not using timer.
Main thing is that if I inspect it wil show the modal data (dont know may be becouse scroll or refresh) and even if i wont mention timer also it wil bind very next after i inspect.
i just wanted to clarify i have used timer becouse after i inspect may be a scroll or refresh it was binding suddenly, i thought may be a symultaneous process of value assgn and opening a modal.
This my html
<div style="display: none">
<button class="primary" #myModalSuccess data-target="#myModalSuccess" data-toggle="modal"
style="cursor: pointer;">Delete</button>
<div id="myModalSuccess" class="modal fade" tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="false"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content" *ngIf="checkOutConfFromRazor">
<div class="modal-header">
<button type="button" (click)="checkSubscriptionAndInvitee()" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="text-center"><img style="height: 80px; " src="assets/img/dashboard/check_circle.svg"></div>
<div class="modal-body">
<h4 class="text-center primary">Payment successful</h4>
<p class="text-center location-text ">Your payment has been proccessed! <br>Details of your transaction are
listed below.
</p>
<div class="ver-divider"></div>
<div class="hor-line"></div>
<div class="ver-divider"></div>
<p class="text-center primary">Transaction ID : <span
class="text-right">{{checkOutConfFromRazor?.id}}</span> </p>
<div class="ver-divider"></div>
<div class="row">
<div class="col">
<label>Transaction Amount</label>
</div>
<div class="col text-right">
<label> {{checkOutConfFromRazor?.amount | slice:0:checkOutConfFromRazor?.amount?.length-2}}
₹</label>
</div>
</div>
<div class="ver-divider"></div>
<div class="hor-line"></div>
<div class="ver-divider"></div>
<div class="row">
<div class="col">
<label>Transaction date</label>
</div>
<div class="col text-right">
<label>{{checkOutConfFromRazor?.created_at | date}}</label>
</div>
</div>
<div class="text-center mt-4">
<button (click)="checkSubscriptionAndInvitee()" class="primary-button-big pl-5 pr-5 pt-1 pb-1"
data-dismiss="modal" style="border: none;">Close</button>
</div>
</div>
</div>
</div>
This is my .ts code
this.subscription = this.userService.verifyCheckOut(val.planId, JSON.stringify(response)).subscribe(value => {
if (value.isVerifyed) {
this.checkOutConfFromRazor = value.payment;
console.log("sucessData" + JSON.stringify(this.checkOutConfFromRazor));
setTimeout(() => {
this.myModalSuccess.nativeElement.click();
}, 20000);
} else {
this.checkOutConfFromRazor = value.payment;
this.myModalFailure.nativeElement.click();
}
});
Related
I am using asp.net core to loop over the list of model objects and in each iteration, I am calling a modal to open with anchor tag. The code is given below.
foreach (var job in Model)
{
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-xl-7 col-md-8 col-sm-12">
<div class="d-flex align-items-start flex-wrap" style="column-gap: 20px; row-gap: 10px;">
<div class="container-icon dark-icon">
<i data-feather="briefcase"></i>
</div>
<div>
<a href="#" class="prev-job" data-id="#job.Id" data-bs-toggle="modal" data-bs-target="#("#j"+job.Id)">
<h2 class="mt-0">#job.Name</h2>
</a>
<p class="text-fade">
#(job.RecruitmentType != null ? job.RecruitmentType : ""),
#(job.Experience != null ? job.Experience + " experience" : "Experience unspecified")
</p>
</div>
<div class="d-flex align-items-center align-self-start">
<i class="fa fa-circle fade-icon"></i>
<span class="text-fade mx-3">
#(job.DatePosted.ToString("dd MMM yyyy"))
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
#await Html.PartialAsync("JobPreview", job.JobPreviewDetails)
}
Using <a href="#" class="prev-job" data-id="#job.Id" data-bs-toggle="modal" data-bs-target="#("#j"+job.Id)", I call the model to open which is displayed in a Partial View.
JobOpening.cshtml PartialView file is given below.
#model BusinessLogicCommon.RequestModel._JobPreview
<div id="#("j"+Model.Id)" class="job-preview modal modal-right fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="row">
<div class="d-flex align-items-start">
<div class="container-icon dark-icon mt-3">
<i data-feather="briefcase"></i>
</div>
<div style="margin-left: 30px;">
<h2 class="fw-500">#Model.JobTitle</h2>
<p class="text-fade">
#(Model.RecruitmentType != null ? Model.RecruitmentType : "Type unspecified"),
#(Model.Experience != null ? Model.Experience + " experience" : "Experience unspecified")
</p>
</div>
</div>
</div>
</div>
The model is not opening and I am getting vendors.min.js:18 Uncaught TypeError: Illegal invocation at Object.findOne (vendors.min.js:18:9132) error.
You need to put your modal data into
<div class="modal-dialog">
<div class="modal-content">
xxxxx
</div>
</div>
Please change your Partial View to:
#model BusinessLogicCommon.RequestModel._JobPreview
<div id="#("j"+Model.Id)" class="job-preview modal modal-right fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="row">
xxxxxx
</div>
</div>
</div>
</div>
Then the modal can show normally.
I believe it is because the syntax for a partial view is #Html.PartialAsync("JobPreview", job.JobPreviewDetails) without need for the "await" at the beginning.
A dialog window is incorrectly opening behind another dialog window. I use the #modalMidWestEquipPlans data target to open the dialog window. How do I tweak the code so that the hyperlink opens the dialog window in front? Most solutions to a similar issue talk about tweaking a z-index but I do not have that in this code.
Thank you
<div class="col col mb-4">
<div class="card metro-card rounded mb-0 bg-primary">
<div class="card-body ">
<h5 class="card-title">
<button type="button" class="btn btn-primary" data-toggle="modal"
data-target="#modalEquipPlans">
Equipment
</button>
</h5>
</div>
</div>
</div>
<div class="modal fade" id="modalEquipPlans" tabindex="-1" role="dialog" aria-labelledby="modalEquipPlansTitle"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title ModalTitleOR" id="modalEquipPlansLongTitle">Equipment</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<strong>Equipment Plans</strong>
<div class="list-group">
<!-- (other list group items removed) -->
<div class="list-group-item bg-danger h5 fake-btn">
<a class="clsPointer" data-toggle="modal"
data-target="#modalMidWestEquipPlans">
<span class="addUnderlines">AFTER CLICKING THIS HYPERLINK, THE DIALOG BOX OPENS BEHIND THIS DIALOG INSTEAD OF IN FRONT</span>
</a>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
I'm trying to display a section of my about page using a full screen modal but the modal is only opening/ showing in a small section. It only opens up a little bit when I use 'modal-dialog modal-lg' but it doesn't expand besides that. Can anyone help me fix this issue?
<!--1-->
<div class="site-section">
<div class="container">
<div class="row align-items-center mr-5">
<div class="col-lg-6 py-5 px-5">
<img src="assets/img/bee.jpg" alt="image" class="img-fluid rounded" style="width:500px;height:500px;">
</div>
<div class="col-lg-6 pl-lg-5 ">
<h3 class="mt-4 font-weight-bold">About Us</h3>
<p class="text-justify pt-0 mr-5"> is a publishing company working with a non- denominational ministry.
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Load More
</button>
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-fullscreen-xxl-down">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="btn-close" data-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</div>
</div>
Try change your bootstrap class form this :
<div class="modal-dialog modal-fullscreen-xxl-down">
To this :
<div class="modal-dialog modal-fullscreen">
Also be sure that you have Bootstrap version 5 installed in your laravel project. Fullscreen modals are only included by default in Bootstrap 5 not in the previous ones: https://getbootstrap.com/docs/5.0/components/modal/#fullscreen-modal
I used vue to populate the item list in my html, and what I want to do, is when the item is clicked, a modal would appear with the data of the clicked item. I'm not using boostrap-vue.
Html:
<div class="row">
<div class="col-lg-4 col-md-6" v-for="items in data" data-toggle="modal" data-target="#exampleModal" user="'items'" click="sendInfo(items)">
<a href="#" class="latest-product__item">
<div class="latest-product__item__pic">
<img src="img/latest-product/lp-1.jpg" alt="">
</div>
<div class="latest-product__item__text">
<h6>{{items.item_name}}</h6>
<div v-for="variant in items.variants">
<div v-for="store in variant.stores">
<span>{{store.default_price}}</span>
</div>
</div>
</div>
</a>
</div>
</div>
Modal:
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<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>
</div>
<div class="modal-body">
<a href="#" class="latest-product__item">
<div class="latest-product__item__pic">
<img src="img/latest-product/lp-1.jpg" alt="">
</div>
<div class="latest-product__item__text">
<h6>{{items}}</h6>
<span>{{items}}</span>
</div>
</a>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success btn-block">Add to Cart</button>
</div>
</div>
</div>
</div>
Vue:
window.onload = function () {
const access_token = "access token here";
new Vue({
el: '#item-data',
data () {
return {
data:[]
}
},
mounted () {
..... API calll .....
},
methonds:{
sendInfo(items) {
this.selectedUser = items;
}
}
})
}
I want to pass the data {{items.item_name}} and {{store.default_price}} to the modal. How do I achieve this?
create a variable for the value you want to pass, a method to handle the event:
data () {
return {
data:[],
passedData:{item_name:null, default_price:null}
},
methods:{
sendInfo(item){
this.passedData = item
}
}
and on the HTML part where you loop through the items:
<div class="col-lg-4 col-md-6" v-for="items in data" data-toggle="modal" data-target="#exampleModal" user="'items'" click="sendInfo(items)">
<div class="latest-product__item__pic">
<img src="img/latest-product/lp-1.jpg" alt="">
</div>
<div class="latest-product__item__text">
<h6>{{items.item_name}}</h6>
<div v-for="variant in items.variants">
<div v-for="store in variant.stores">
<span>{{store.default_price}}</span>
</div>
<a href="#" class="latest-product__item" #click="sendInfo({item_name:items.item_name,default_price:store.default_price})">
Show Modal
</a>
</div>
</div>
</div>
Modal:
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<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>
</div>
<div class="modal-body">
<a href="#" class="latest-product__item">
<div class="latest-product__item__pic">
<img src="img/latest-product/lp-1.jpg" alt="">
</div>
<div class="latest-product__item__text">
<h6>{{passedData.item_name}}</h6>
<span>{{passedData.default_price}}</span>
</div>
</a>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success btn-block">Add to Cart</button>
</div>
</div>
</div>
</div>
Use common Vue instance for modal and HTML block to access the same data as. Suppose:
<div id='#item-data'>
<div>
//basic Html code
<div>
<div>
//modal code
<div>
<div>
then you can access same vue instance variable in your HTML and modal.
I'm going to assume that your modal markup is somewhere inside the element with the ID 'item-data', and so has access to the data in your Vue instance.
The first thing you need to do is declare selectedUser as a data property, as Vue needs to know about it upfront:
data () {
return {
data:[],
selectedUser: null,
}
},
Next, you need to change your modal markup slightly, so it's referring to the currently selected item (e.g the heading would be {{selectedUser.item_name}} instead of {{items}}).
Lastly, the syntax is wrong where you're attaching a click handler to your item row. Instead of click="sendInfo(items)" it should be #click="sendInfo(items)".
I am working in an eCommerce application ,In this I have cart icon .What I want to do is when I click on the cart icon I want to show a modal screen with the user selected product data .
But in my case for the first time after page loads modal screen opens after double click,afterwards it opens with the single click .
icon :
<i class="fas fa-cart-plus fa-flip-horizontal text-primary" (click)="get_My_Cart($event)" data-toggle="modal" data-target="#exampleModal" style="font-size:25px;cursor: pointer;"></i>
Modal :
<div *ngIf="mycart && mycart.length" class="modal fade modalstyle" 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 headerHeight text-white " style="background:rgb(0, 0, 0);font-weight:bold">
<h6 class="modal-title" id="exampleModalLabel">My Cart Items</h6>
<button #closeModalBtn type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div *ngFor="let products of mycart;let i =index;">
<div class="container col-sm-12">
<div class="row">
<div class="col-sm-4 paddingforimage">
<img [src]="products['ITEM_IMAGE_PATH']">
</div>
<div class="text-info col-sm-6">
<span>
<h6>{{products?.TOTAL_QTY}} × {{products?.ITEM_PRICE}} ₹</h6>
</span>
<span>
<h6>{{products?.ITEM_DESC}}</h6>
</span>
<span>
<h6>{{products?.TOTAL_AMT}} ₹</h6>
</span>
</div>
<div class="col-sm-1 text-right">
<button type="button" class="close closebtn" aria-label="Close" (click)="detele_My_Cart(products?.ITEM_CODE)">
<span aria-hidden="true" (click)="detele_My_Cart(products?.ITEM_CODE)">×</span>
</button>
</div>
</div>
</div>
<hr>
</div>
<div class=" container row col-sm-12">
<div class="col-sm-6">
<strong>SHIPPING</strong>
</div>
<div class="col-sm-6 text-right">0 ₹</div>
<hr>
<div class="col-sm-6">
<strong>TOTAL</strong>
</div>
<div class="col-sm-6 text-right">{{my_Cart_Total_Amount}} ₹</div>
</div>
<br>
<div class="container row col-sm-12" id="wrapper">
<button type="button" class="btn btn-success buttonSize" data-dismiss="modal" routerLink="/cartsummary">
<strong>CHECK OUT</strong>
</button>
</div>
</div>
</div>
</div>
</div>
Component:
get_My_Cart($event) {
this.publicIp.v4().then(ip => {
this.CartdataService.get_My_Cart_Products(ip).subscribe(
data => {
this.mycart = data['Table']
this.my_Cart_Total_Amount = data['Table1'][0]['TOTAL_AMOUNT']
});
});
}
Here in modal screen I have a validation ,Modal screen is open if data is bind in it otherwise it will not .(modal will not open if the cart is empty).
*ngIf="mycart && mycart.length"
If I remove this validation from the modal screen it works ,but it always opens (if there is no product in cart and user clicked on the cart icon it opens but I want to restrict it .)
can anyone tell me how to handle this issue ..
The flow of code is not correct.
Anyway, I think, you're using jQuery & Bootstrap.js. (Bad Idea)
You can programmatically trigger the modal using $('#exampleModal').modal('show') once data comes from server.
declare var $ :any;
get_My_Cart($event) {
this.publicIp.v4().then(ip => {
this.CartdataService.get_My_Cart_Products(ip).subscribe(
data => {
this.mycart = data['Table']
this.my_Cart_Total_Amount = data['Table1'][0]['TOTAL_AMOUNT']
if(this.mycart && this.mycart.length)
$('#exampleModal').modal('show')
});
});
}
But there is a simple workaround in this case. Try to toggle display property of CSS instead of removing it from DOM using *ngIf.
<div [ngStyle]="{display: mycart && mycart.length ? 'block':'none'}" class="modal fade modalstyle">
</div>