Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8223229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:36:57+00:00 2026-06-07T14:36:57+00:00

$(‘.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

  • 0
$('.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;
                });

I seem to have tried evrything to stop the event from doubling each time the button is clicked. The code was originally inside another function which opened up a ‘pop-up’ style box but even when I move it outside the function it still seems to bubble.

As requested:-

$(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;
                });


            }

        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:36:59+00:00Added an answer on June 7, 2026 at 2:36 pm

    The problem is that you’re hooking up the event handler more than once. Each time an element matching '.bottom_links .lister a' is clicked, provided various conditions are right, you re-run this code:

    $('.add_instruction_btn').click(function(e){
        // ....
    });
    

    Each time you run that code, you hook up a new copy of the handler.

    If the set of elements matching '.add_instruction_btn' is fixed, just move that code out of the click handler for '.bottom_links .lister a' elements.

    If the set of elements matching '.add_instruction_btn' varies, you still want to move the code outside the click handler for '.bottom_links .lister a' elements, but you probably want to make it use event delegation, too, as you do with the '.bottom_links .lister a' one.

    A note about event delegation: You’re “rooting” your event delegation on document, which is really, really high up. It’s best to root delegation in the nearest container you can to the elements you’re watching for. Obviously, if document is the nearest container, well, there you are, but there’s usually something a bit further down you can use instead, while still getting the benefits of delegation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is how I get the tags of a body of text. var tags
I need a function that will clean a strings' special characters. I do NOT
I have a reasonable size flat file database of text documents mostly saved in
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
I was writing code for dragging mechanism which invokes to wait for small period
I've got a string that has curly quotes in it. I'd like to replace
I downloaded PostgreSQL from the official website and ran the .dmg installer. After that
I'm running a Octopress blog which is based on Jekyll . Now I wanted
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.