动态添加锚标记,单击该锚标记会打开一个表单以更新数据。但是,当单击下一个锚标记时,表单提交将运行两个或更多个。
$(document).on("click", ".edit_edu", function(e) {
e.stopPropagation();
var edu_row_id = $(this).parents('.edu_rows').find('#edu_row_id').text();
UIkit.modal('#edit_edu_course',function () {}).show();
$('#educational_edit_records_form').submit(function () {
$(this).ajaxSubmit({
url: '<?php echo base_url("Resume/update_karjoo_educational_info") ?>/'+edu_row_id,
resetForm:true,
success: function () {
UIkit.modal('#edit_edu_course').hide();
UIkit.notification('well done!',{status:'primary',pos: 'bottom-right',timeout: 3000});
},
fail: function () {
UIkit.notification('try again!',{status:'danger',pos: 'bottom-right',timeout: 3000});
}
});
return false;
});
});
UIkit.util.on('#new_edu_course','hide',function () {
$('#edu_list').empty();
$.getJSON('<?php echo base_url('Resume/get_edu_fields/'.$cu_username)?>', function (response) {
$.each(response,function (key,val) {
$('<li class="edu_rows">'+'<span class="uk-hidden" id="edu_row_id">'+val.id+'</span>'+'<small class="uk-label uk-label-success">'+val.grade+'</small>'+'<span uk-icon="icon:chevron-right"></span>'+'<small class="uk-text-bold">'+val.field_name+'</small>'+'<span uk-icon="icon:chevron-right"></span>'+'<small class="uk-text-bold">'+val.uni_type+'</small>'+'<span uk-icon="icon:chevron-right"></span>'+'<small class="uk-text-bold">'+val.uni_name+'</small>'+'<ul class="uk-iconnav uk-float-left">'+'<li>'+'<button type="button" uk-tooltip="title:ویرایش" class="uk-text-warning edit_edu" uk-icon="icon: file-edit"></button>'+'</li>'+'<li>'+'<button type="button" uk-tooltip="title:حذف" class="uk-text-danger del_edu" uk-icon="icon: trash"></button>'+'</li>'+'</ul>'+'</li>').appendTo('#edu_list');
})
})
});
答案 0 :(得分:0)
您有2个元素,其类名为'edit_edu'。
这将解释它。 检查:
$('.edit_edu').length