![](/img/trans.png)
[英]is it posible to use partialview with modal inside of another partialview and display the modal on the main page?
[英]How to trigger another modal from PartialView
我試圖在當前模態內觸發另一個模態。 我當前的模態來自PartialView
並且它運行良好,讓我向您展示
我的觀點是當用戶單擊第一個模式內部的View Cart
按鈕時觸發購物車。 所以第一步是關閉當前模態並觸發另一個模態。 讓我向你展示我的購物車;
所以我希望你們明白我想表達的意思。 我的代碼被吼叫;
Html :
<div class="col-12 col-lg-6">
<a href="#" class="tt-cart-total" id="currentCountOfCartForModal">
There are 1 items in your cart
<div class="tt-total">
TOTAL: <span class="tt-price">$324</span>
</div>
</a>
<a href="#" class="btn btn-border btn-close-popup">CONTINUE SHOPPING</a>
<a data-target="/Base/CartPartialView/" class="sepet btn btn-border">VIEW CART</a> //That's the link which is gonna trigger to Shopping Cart
<a href="@Url.Action("CardIndex","Payment")" class="btn">PROCEED TO CHECKOUT</a>
</div>
劇本 :
<script>
$(function () {
$(".modal-body").on("click", ".sepet", function () {
document.getElementById("modalClose").click();
var url = $(this).data("target");
console.log(url);
$.post(url, function (data) { })
.done(function (data) {
$("#modelView .tt-cart-content").html(data);
})
.fail(function () {
$("#modelView .tt-cart-content").text("Error!!");
})
});
})
</script>
這對我來說是這樣的: Gif
您必須等待模態完全關閉,然后在您的購物車模態上調用show
,或者只是在您的鏈接上觸發一個點擊事件。
例子:
$('#YOUR_MODAL_SELECTOR_WHICH_YOU_CLOSE').on('hidden.bs.modal', function () {
//...
$('a.sepet').click();
//...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.