私のコードでは、無効になっているテキストボックスが1つあります。ユーザーが編集鉛筆アイコンをクリックすると、編集用のテキストボックスが有効になります。テキストボックスを編集するときには、編集済みの値がすでに終了しているかどうかをチェックする必要があります。それのために私はコールcheckOwnerIdメソッドを持っています。その機能には何の呼び出しもありません。テキストボックスの編集時にjQuery関数を呼び出す方法
これは私のjQueryのコード
var parcel = $('#parcel_no').val();
$('#pin-edit').click(function() {
$('#owner_id_txt').removeAttr("disabled");
$("#pin-edit").hide();
$("#save-pin").show();
oldOwnerId = $('#owner_id_txt').val();
});
$('#save-pin').click(function() {
if ($("#owner_id_txt").val() == "") {
displayErrorMessage('Please enter owner Id');
$("#owner_id_txt").focus();
$('#owner_id_txt').val(oldOwnerId);
return;
}
$("#pin-edit").show();
$('#owner_id_txt').attr("disabled", true)
$("#save-pin").hide();
var data = { 'owner_id': $("#owner_id_txt").val(), 'parcel_no': parcel };
BlockUI();
var urlstring = "@Url.Content("~")Parcel/UpdateOwnerId";
$.post(urlstring, data, function (result) {
UnblockUI();
if (result.success == true) {
displaySuccessMessage('Owner Id updated successfully!');
}
else {
displayErrorMessage('There was an error while updating Owner Id!');
}
});
$('#owner_id_txt').change(function() {
//alert("Check Exist or Not");
var data = { 'owner_id': $("#owner_id_txt").val() };
var urlString = "@Url.Content("~")Parcel/CheckOwnerId";
urlString = sanitize_url_path(urlString);
$.post(urlString, data,
function (result) {
if (result) {
displayErrorMessage("Owner Id already exists");
$("#pin-edit").show();
$('#owner_id_txt').attr("disabled", true);
$("#save-pin").hide();
}
});
})
});
があなたのコードに関連するすべてのHTMLオブジェクトを追加してください。 – reporter