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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:15:51+00:00 2026-06-11T01:15:51+00:00

I have a table which runs a function on click event of it’s row.

  • 0

I have a table which runs a function on click event of it’s row. It is working perfectly fine but when a tr is added to this table by AJAX then I am not able to fire click event of this row or we can say click event is not firing for this row besides other rows are still able to fire click event.

$('div.dashboard-content table.list tbody tr').click(function(){
var id = $(this).attr('id');
$('div.dashboard-content table.list tr td').css({'background': '#ffffff','font-weight':'normal'});
$('div.dashboard-content table.list thead td').css({'background': '#EFEFEF','font-weight':'bold'});
$('tr[id='+ id + '] td').css({'background': 'lightblue','font-weight':'bolder'});
$.get(
        'index.php?route=sale/order/infoforhome&token=<?php echo $token; ?>', 
        { 'order_id' : id }, 
        function(data){
            if(data)
            {
                $('#oder_detail').html
                ('<table>' +
                    '<tbody>' + 
                        '<tr>'+
                            '<td style="font-weight:bold;">' +
                                '<?php echo $column_orderid; ?>:'+
                             '</td>'+
                             '<td>' + 
                             data['orderid'] + 
                             '</td>'+
                         '</tr>' + 
                         '<tr>'+
                            '<td style="font-weight:bold;">'+
                            '<?php echo $column_customername; ?>:'+
                            '</td>'+
                            '<td>'+ 
                            data['name']  +
                            '</td>'+
                         '</tr>'+
                         '<tr>'+
                            '<td style="font-weight:bold;">'+
                            '<?php echo $column_shippingaddress; ?>: '+
                            '</td>'+
                            '<td>'+ 
                            data['address'] +
                            '</td>'+
                         '</tr>'+
                         '<tr>'+
                            '<td style="font-weight:bold;">'+
                            '<?php echo $column_telephone; ?>:'+
                            '</td>'+
                            '<td>'+ 
                            data['telephone'] +
                            '</td>'+
                         '</tr>'+
                         '<tr>'+
                            '<td style="font-weight:bold;">'+
                            '<?php echo $column_orderstatus; ?>:'+
                            '</td>'+
                            '<td>'+ 
                            data['orderstatus'] +
                            '</td>'+
                         '</tr>'+
                         '<tr>'+
                            '<td style="font-weight:bold;">'+
                            '<?php echo $column_ordertotal; ?>:'+
                            '</td>'+
                            '<td>'+ 
                            data['total'] +
                            '</td>'+
                         '</tr>'+
                    '</tbody>'+
                '</table>');
            }
            else
            {
                $('#order_detail').html('Sorry No Details exists for this order in the database');
            }
        }, 'json');

});


function getLatestOrders() {
var last_order_id = $('div.dashboard-content table.list tbody tr:first').attr('id');
$.get(
    "index.php?route=common/home/latest&token=<?php echo $token; ?>",
    {'order_id' : last_order_id },
    function (data) {
  if (data) {
    for (var i = 0; i < data.length; i++) {
      $('div.dashboard-content table.list tbody tr:first').before(
        '<tr id="' + 
        data[i]['order_id'] + 
        '"><td class="right">' + 
        data[i]['order_id'] + 
        '</td><td class="left">' + 
        data[i]['customer'] + 
        '</td><td class="left">' + 
        data[i]['status'] + 
        '</td><td class="left">' + 
        data[i]['date_added'] + 
        '</td><td class="right">' + 
        data[i]['total'] + 
        '</td><td class="right"> [<a href="' + 
        data[i]['action']['href'] + '">' + 
        data[i]['action']['text'] + 
        '</a>]</td></tr>'
      );
    }
  }
}
}
  • 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-11T01:15:53+00:00Added an answer on June 11, 2026 at 1:15 am

    You need to bind the click function to a parent element so the event can properly bubble. I can see no structure so I’m going to make some assumptions here.

    //bind to document.
    $(document).on('click', 'table > tr', function(){
      //now all rows will have a click function, regardless of ajax.
      alert('Expected click fired.');
    });
    

    the .on() method is used in versions later than 1.7 to handle event delegation. In previous versions, we use .delegate().

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

Sidebar

Related Questions

I have table in which I am inserting rows for employee but next time
i have a table which has many fields but i want to get count
I have a table which stores the data related to posts in this format
I have a function which runs to insert a filename and a part number
I have this great function that parses a field into a pivot table consisting
I have a really annoying problem. I got this bunch of code which runs
I have an SQL LIKE query running on mySQL which runs fine on my
I have SMO code which copies tables from one database to another. It runs
I have table which contains double values stored in mysql database ...I need to
I have a table which i want to store all the outputs into one

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.