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

  • SEARCH
  • Home
  • 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 6861853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:35:18+00:00 2026-05-27T02:35:18+00:00

So in my datatable, I have buttons that allow the record to be edited.

  • 0

So in my datatable, I have buttons that allow the record to be edited. I am using JQuery to style and give functions to the button click. The only way to get the JQuery to be applied to the buttons, is by putting the code inside the fnDrawCallback option of the table. However, it causes multiple instances of the functions!
For instance, just to test I am creating an alert to give me the button id (which is the record id) when the button is clicked. And instead of just alerting me ONCE, it gives me several alerts!

Any ideas?

*As a side note, I have tried declaring the functions inside the fnInitComplete option but that only applies the function to the first set of records that is displayed (i.e. 10). Once I show more records or go to the next page, the functions dont work on those records.

var tfTable = $('.mypbhs_truforms').dataTable({
        "bProcessing": true,
        "sAjaxSource": 'sql/mypbhs_truforms.php?accountid=<?PHP echo $accountid;?>',        
        "aaSorting": [[ 1, "asc" ]],
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        //"bStateSave": true, //Use a cookie to save current display of items
        "aoColumns": [
            {"asSorting": [  ], "sClass":"center"},
            null,
            null,
            null,
            null,
            null,
            {"asSorting": [  ], "sClass":"center"},
        ],
        "fnDrawCallback": function(){
            //EDIT OFFICE FORM
            $('.mypbhs_edit_truform_button').click(function(){
                var tf_id = $(this).attr('id');
                alert(tf_id);
            });
        },
        "bScrollCollapse": true,
        "sScrollX": "100%",
         "fnInitComplete": function() {
                tfTable.fnAdjustColumnSizing();
         }
    });
  • 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-05-27T02:35:19+00:00Added an answer on May 27, 2026 at 2:35 am

    Ok so found a way around this. Using JQuery’s .on function for all the functions I was placing in the fnDrawCallback option.
    I am curious why using fnDrawCallback is creating multiple instances of the same function though if anyone has an answer to that.

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

Sidebar

Related Questions

I have a column with buttons in a table I'm using jQuery datatable plugin.
I current have a datatable that has a button for each record that when
I have created a user control that contains a button. I am using this
I have a page with a button that when I click, it retrieves data
I am using a datatable and for each row I have two buttons, an
I use yui datatable in my asp.net application... I have a link button in
I have a DataTable that queries out something like below usergroupid...userid......username 1.............1...........John 1.............2...........Lisa 2.............3...........Nathan
I have a DataTable that has a boolean column called [Invalid]. I need to
I have a datatable that has a date column, but I am stumped as
I have to avoid page refresh. Every time I click the submit button, page

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.