$('.add_instruction_btn').click(function(e){
e.preventDefault();
var ins_content=$('#add_instructions').val();
var id=$('.useri').val();
if(ins_content!="")
{
//write new instructions to database
var id=$('.useri').val();
var data="job_id="+job_idx+"&ins="+ins_content+"&client_id="+id+"&key=2";
$.ajax({
type:"POST",
url:"admin_includes/get_instructions.php",
data:data,
success:function(html2){
alert(html2);
}
});//end ajax
}
return false;
});
每次单击按钮时,我似乎都尝试过阻止事件翻倍。该代码最初位于另一个打开“弹出式”样式框的函数内,但即使我将其移到函数外,它似乎仍然冒泡。
按照要求:-
$(document).on('click', '.bottom_links .lister a', function(e){
//e.preventDefault();
//e.stopPropagation();
$('.ind_ins').text("");
var ident=$(this).data('ref1');
if(ident==1){
var job_idx=$(this).data('job_id');
var cl_name=$(this).data('cl_name');
var icon_stat=$(this).data('img_id');
var id=$('.useri').val();
if(icon_stat=="1")
{
$('.opaque_scr,.instruction_popup').css('visibility', 'visible');
$('.instruction_popup h2').html("Add Instructions for Appointment ID: "+job_idx);
$('.client_name').html("<strong>Client Name: </strong>"+cl_name);
//get original instructions
var get_job="job_id="+job_idx+"&key=1";
$.ajax({
type:"POST",
url:"admin_includes/get_instructions.php",
data:get_job,
success:function(html){
var split_data=html.split("^");
var split_data_count=split_data.length-1;
var ins_tb="<table width='100%'>"
for(var xs=0;xs<split_data_count;xs++)
{
var ind=split_data[xs].split("|");
var ind_count=ind.length-1;
for(var xx=0;xx<ind_count;xx++)
{
ins_tb+="<tr><td width='75%'>"+ind[0]+"</td><td>"+ind[1]+"</td></tr>";
}
}
ins_tb+="</table>";
$(ins_tb).appendTo('.ind_ins');
}
})//end ajax
$('.add_instruction_btn').click(function(e){
e.preventDefault();
e.stopPropagation();
var ins_content=$('#add_instructions').val();
var id=$('.useri').val();
if(ins_content!="")
{
//write new instructions to database
var id=$('.useri').val();
var data="job_id="+job_idx+"&ins="+ins_content+"&client_id="+id+"&key=2";
$.ajax({
type:"POST",
url:"admin_includes/get_instructions.php",
data:data,
success:function(html2){
alert(html2);
}
});//end ajax
}
return false;
});
}
}