How can bootstrap's modal get the value from one row?

How can bootstrap's modal get the value from one row?

donnydongdonnydong Posts: 1Questions: 1Answers: 0
edited October 2014 in Free community support

I use server-side to get data from server successfully. Now I add a button inside a <td></td>. There'll be a modal shown when the button clicked. I hope show more info than data inside table. For example, there are first_name,last_name,position,office shown in the table. But except for them,I hope show sex,year,interest,etc on the modal.

I don't know how to do.

$(document).ready(function() {
$('#example').dataTable( {
"processing": true,
"serverSide": true,
"ajax": "../server_side/scripts/server_processing.php"
} );
} );

Here's the part of code in server_processing.php.

$columns = array(
array( 'db' => 'first_name', 'dt' => 0 ),
array( 'db' => 'last_name', 'dt' => 1 ),
array( 'db' => 'position', 'dt' => 2 ),
array( 'db' => 'office', 'dt' => 3 ),

Here's the code to show info on the modal.

$('#example tbody').on('click', 'tr', function () {

    var name = $('td', this).eq(1).text();
 var position = $('td', this).eq(2).text();
 var year = $('td', this).eq(5).text();

 $("#currentuser").text(name);   // It works.
 $("#position").text(position);    // It works.
 $("#year").text(year);    // It fails.


} );
This discussion has been closed.