0

I need to get the value from column RR from the same raw the button is clicked

the problem here is that the code only works when i use evaluate in console in google developer tools

Table :

 <div class="tableDiv" align="left">
         <table id="example" class="display" align="center">
           <thead>
             <tr style="color: #D2002E; background: #FFCC01;">
               <td  >Date</td>
               <td>RR</td>
               <td>Origin</td>
               <td>Destination</td>
               <td>CNEE</td>
               <td>Status</td>
               <td>Details</td>
             </tr>
           </thead>
           <tbody id="table_body">
           </tbody>
         </table>
       </div>

data values for each row :


  var rootRef = firebase.database().ref().child("Requests");  

    rootRef.on("child_added", snap =>{


    var DateValue = snap.child("Date").val();
    var RRValue = snap.child("RR").val();
    var OrgValue = snap.child("Origin").val();
    var DestValue = snap.child("Destination").val();
    var CustAccValue = snap.child("Customer Account").val();
    var StatusValue = snap.child("Status").val();

    if (StatusValue != "Done")
    {


      $("#table_body").append("<tr><td " + DateValue + 
      "</td><td class=\"valueRRField\">" + RRValue + 
      "</td><td>" + OrgValue + 
      "</td><td>" + DestValue + "</td><td>" + CustAccValue + "</td><td>" + StatusValue + "</td><td><Button onclick=\"expandTriggered()\" class=\"lisnClick\">" + "details" + "</Button></td></tr>");
    }

here where the code does not work only when using evaluate


  $(".lisnClick").click(function() {
    var refer = $(this).closest("tr")    
                       .find(".valueRRField")     
                       .text();        

                       alert(refer);       // Output
  });
A.A.AlJamal
  • 130
  • 11
  • have you tried to enter the click function into `document.ready`? it's probably a loading sequence problem – fedesc Apr 16 '19 at 12:26
  • tried to add `document.ready?` as below still need to use evaluate `$(document).ready(function(){ $(".lisnClick").click(function(){ var refer = $(this).closest("tr") .find(".valueRRField") .text(); alert(refer); // Output }); });` – A.A.AlJamal Apr 16 '19 at 12:34
  • You can try: `$('#table_body').on('click', '.lisnClick', function(){ // your code here.. });` – palaѕн Apr 16 '19 at 12:40
  • Thank you it worked perfectly , not sure how to mark you comment as the solution – A.A.AlJamal Apr 21 '19 at 13:28

0 Answers0