내 $(document).ready()
함수에서 집합 또는 라디오 버튼에 바인딩 된 .change
이벤트가 있습니다. 그러나 사용자가 제출하는 양식에 오류가있는 경우 페이지는 사용자가 선택한 값으로 다시로드됩니다. 이로 인해 페이지가로드 될 때마다 라디오 버튼 .change
이 작동하지 않으므로 원하지 않습니다. 어떻게하면이 기능을 비활성화 할 수 있습니까?페이지로드시 .change 함수를 비활성화하는 방법
편집
여기 그것 때문에 지금 중간에 뜨거운 엉망 마음에서이 글의 가독성을 유지하려고했던 사실 이전에 게시되지 않은 전체 기능입니다.
FYI - 사용자가 양식을 제출 한 후에 오류가 발생하면 사용자가 제출 버튼을 눌렀을 때와 같이 양식을로드 할 페이지가 필요합니다. 라디오 버튼 선택에 따라 div
및 span
요소 집합을 표시하므로 trigger('change')
메서드를 사용했습니다. 페이지로드 중에 작업이 발생하는지 감지 할 수있는 방법이 있습니까? 당신이 자동 완성 신경 쓰지 않는 경우
$('input[name=TransactionType]').change(function (e) {
//Clear any messages from previous transaction
$('.error').text('');
$('.success').text('');
//Display fieldset Submit and Cancel(back to search) link
$('#PageDirection').show();
$('#AgentInformation').show();
//Display input fields
var radioValue = $(this);
if (radioValue.attr('id') == "Enroll" || (radioValue.attr('id') == "ModT")) {
//Enable and disable input boxes
$('span').not('#AllInput').hide();
$('#AllInput').show();
$('#PayFrequency').show();
$('#refNumberInput').show();
//Set tooltips
$('#AccountType').removeAttr("title");
if (radioValue.attr('id') == "Enroll") {
$('#PaymentFrequency').removeAttr("title");
$('.req').show();
$('#refNumberInput').show();
$('#enrollNote').show();
} else {
$('#PaperStatement').show();
$('#PaymentFrequency').attr("title", "Select the frequency to pay the distributor");
$('#refNumberInput').show();
}
} else if (radioValue.attr('id') == "New") {
$('span').not('#NewMessage').hide();
$('#NewMessage').show();
$('.req').show();
$('#refNumberInput').show();
} else if (radioValue.attr('id') == "ModA") {
$('#AllInput').show();
$('#AgentIdSpan').show();
$('.req').show();
$('#UnenrollMessage').hide();
$('#NewMessage').hide();
$('#PayFrequency').hide();
$('#PaperStatement').hide();
$('#refNumberInput').show();
$('#AgentId').attr("title", "Enter the Agent ID to be modified");
} else if (radioValue.attr('id') == "Clone") {
$('span').not('#AgentIdSpan').hide();
$('#AgentIdSpan').show();
$('.req').show();
$('#AgentId').attr("title", "Clone EFT onto this Agent ID");
} else if (radioValue.attr('id') == "Unenroll") {
$('span').not('#UnenrollMessage').hide();
$('#UnenrollMessage').show();
$('.req').show();
$('#refNumberInput').show();
}
if (radioValue.attr('id') != "Clone") {
$('.alwaysReq').show();
};
}).filter(':checked').trigger('change');
의 변경 방법을 트리거하는 것처럼
.trigger('change')
방법을 제거하세요? HTML 형식은 어떤 모양입니까? – grammartrigger()를 호출하지 않으면 페이지가로드 될 때마다 change 함수가 실행되지 않습니다. 변화에 대한 등록 및 화재 발생. – Krishna
프로그래밍 방식으로 상태를 변경하거나 라디오를 실제로 변경해야하거나 trigger()를 호출하면 변경 기능이 실행되지 않습니다. – adeneo