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 6886099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:43:02+00:00 2026-05-27T05:43:02+00:00

I am trying to insert buttons into the JQuery DataTables but it seems that

  • 0

I am trying to insert buttons into the JQuery DataTables but it seems that when the button is pressed, nothing happen.

The code as follows (for the JQuery Datatable):

            var oTable = $('#example').dataTable( {
                "aaData": movieclips,
                "bProcessing": true,
                "bAutoWidth": false,
                "fnInitComplete": function() {
                                var oSettings = this.fnSettings();
                                for ( var i=0 ; i<oSettings.aoPreSearchCols.length ; i++ ){
                                    if(oSettings.aoPreSearchCols[i].sSearch.length>0){
                                        $("tfoot input")[i].value = oSettings.aoPreSearchCols[i].sSearch;
                                        $("tfoot input")[i].className = "";
                                    }
                                }
                            },
                "aoColumns": [
                    { 
                        "sTitle": "Title", 
                        "sClass": "center",
                        "sWidth": "80%"
                    },
                    { 
                        "sTitle": "Video URL",
                        "sClass": "center",
                        "fnRender": function(obj) {
                            var sReturn = obj.aData[ obj.iDataColumn ];
                            var returnButton = "<input class='approveButton' type='button' name='" + sReturn + "' value='Play'></input>";
                            return returnButton;
                        },
                        "sWidth": "20%"
                    }
                ]
            } );

The approveButton function as follows:

        $(".approveButton").click(function() {
            alert(this.name);

           try {
              alert(this.name);
           } finally {
              return false;
           }
        }

Any Insight?

  • 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-27T05:43:02+00:00Added an answer on May 27, 2026 at 5:43 am

    If you assign the handler with $(".approveButton").click(...) it will only apply to elements that already exist which match the ".approveButton" selector at that moment. That is, elements created later will not automatically get handlers of their own. I’m assuming that that is the problem – if not you can disregard the following…

    Fortunately there is a mechanism for creating a handler that will automatically work on matching elements that are created in the future:

    $(document).on("click", ".approveButton", function() {
       // your function code here
    });
    

    Notice that the initial selector is document – this will work, but you should set it up on a parent element closer to your buttons if you can, so perhaps the following:

    $("#example").on("click", ".approveButton", function() { /* your code */ });
    

    (I’m not sure if “#example” is the most appropriate parent for this purpose, but you don’t show any of your HTML, so…)

    Have a look at the jQuery doco for .on() for more information.

    Or, if you’re using a version of jQuery older than 1.7 you can use `.delegate()’

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

Sidebar

Related Questions

I'm trying to insert reCaptcha code into my page from jQuery, but it doesn't
I'm trying to create a post button that inserts the latest posts into a
I'm trying to insert some import lines into a python source file, but i
I was trying to insert new data into an existing XML file, but it's
I'm trying to insert text into an html textbox when the user pushes buttons.
I'm trying to create a toolbar button that inserts a footer (including some buttons)
I'm having trouble trying to properly insert additional code into the onclick attribute of
I'm trying to insert a text into a UITextField . But by insert, I
I am trying to insert some extra code into the current tab page in
I'm trying to insert records into DB using AJAX. I'm not sure why, but

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.