PHP를 통해 인쇄되는 HTML 요소에 대한 유효성 검사를 시도했지만 작동하지 않지만 PHP없이 동일한 HTML을 넣을 때 작동합니다. 여기 jQuery가 PHP를 통해 인쇄 요소에서 작동하지 않는 이유는 무엇입니까?
function fetch_all() {
var form_name = 'package_form2';
$.post('ajax/ajax_form_get_all_packages.php',{form_name:form_name}, function(result) {
console.log(result);
$('#live_data').html(result);
});
} fetch_all();
가 아약스를 통해 에코됩니다 실제 데이터입니다 :
여기
<div class="row" id="live_data">
// here will all radio buttons and images echo via ajax
</div>
는 AJAX입니다 : 아래
은 실제 데이터가 AJAX를 통해 인쇄 할 수있는 HTML입니다$output .= '
<div class="col-md-4">
<label for="'.$id.'">
<img src="uploads/'.$img.'" class="img-responsive">
</label>
<div>
<div class="radio text-center">
<input type="radio" id="'.$id.'" value="'.$code.'" name="optradio" class="optradio">
</div>
</div>
</div>
';
다음은 FormValidation 코드입니다.
$(document).ready(function() {
$('#menu1_info').formValidation({
message: 'This value is not valid',
icon: {
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
optradio: {
validators: {
notEmpty: {
message: 'Please choose one of the Package'
}
}
}
}
})
.on('success.form.fv', function(e) {
// Prevent form submission
e.preventDefault();
// Get the form instance
var $form = $(e.target);
// Get the BootstrapValidator instance
var fv = $form.data('formValidator');
$form.bootstrapValidator('disableSubmitButtons', false);
});
});
안녕하세요 정말 감사하다 가장 가까운 정적 부모에게 위임 할 수 있습니다, 당신 솔루션이 올바른지, 나는 나의 질문을 편집 당신은 또한 BootstrapValidator가 PHP에 의해 인쇄되는 요소에서 작동하지 않는 이유를 말해 줄 수 있습니까 –
문제는 존재하지 않는 요소를 선택하려고하는 것입니다 ('optradio'클래스가있는 요소 없음). – kapantzak
BootstrapValidator는 요소 이름으로 요소를 가져오고 이름 요소로만 작동해야하지만 이름에는 작동하지 않습니다. ( –