-1
私は私のカートアイテムの数量を更新するには、次のコードを持っている:ショッピングカートアップデート数量onKeyUpを
<div class="cart-col cart-col-qty" data-caption="Quantity">
<div id="[email protected]_id">
@Html.TextBoxFor(model => model.CartItems[ix].Count,
new
{
@class = "test11 form-control",
@type = "text",
@min = "0"
})
<a href="#" class="RefreshQuantity tessss btn btn-danger btn-to-danger btn-sm btn-icon" data-id="@item.item_id"
txt-id="[email protected](ix)__Count"><i class="fa fa-2x">+</i></a>
</div>
私はこのコードでanchor
要素をクリックすると、POSTリクエストを作るために、AJAXを使用しています:
anchor
にクリック機能を削除し、cartItem IDと数量のウィットでAJAXリクエストを作るために、入力のOnKeyUpイベントを使用したい
$(".RefreshQuantity").click(function() {
// Get the id from the link
var recordToUpdate = $(this).attr("data-id");
var countToUpdate = $("#" + $(this).attr("txt-id")).val();
if (recordToUpdate != '') {
// Perform the ajax post
$.post("/ShoppingCart/UpdateCartCount", { "id": recordToUpdate, "cartCount": countToUpdate },
function (data) {
// Successful requests get here
// Update the page elements
if (data.ItemCount == 0) {
$('#row-' + data.DeleteId).fadeOut('slow');
}
location.reload();
});
}
});
ページのリフレッシュ。どうすればこれを達成できますか?
は
私のコードスニペットを見て再び代わりに.clickの本を使用し、あなたの答えは –
変更をどのように動作するか私に言うことができるこの:$(「RefreshQuantity。」)((機能をクリック)します。これは:$( "#YourElement")。on( 'keyup'、function(e)、基本的に... – JCM