How to have button click event separated from button click event

How to have button click event separated from button click event

dan-zdan-z Posts: 10Questions: 2Answers: 0

i have been trying to have separate button click event and row click event. how ever when i try to edit a tuple using a button click event row click event triggers.

Below is my table loading and row click event.

$(document).ready(function () {
            var dataTable;
            $('#Person').parsley();

            $.ajax({
                url: "/Details/GetAllDetails",
                type: "Get",
                datatype: "json",
                success: function (data) {

                    dataTable = $("#persondatatable").DataTable({
                        select: true,
                        data: data,
                        columnDefs: [
                            {
                                "click": false, "targets": [6],
                                "width": "24%"
                            }
                        ],
                        columns: [
                            { "data": "Id", "visible": false },
                            { "data": "Firstname" },
                            { "data": "LastName" },
                            { "data": "PhoneNo" },
                            { "data": "Email" },
                            { "data": "SSN" },
                             {
                                 "data": "Id", "render": function (data) {

                                     return '<a class="btn btn-primary" style="margin-left:30px"  onclick="editdetails(' + data + ')">Edit</a>   <a class="btn btn-danger" style="margin-left:5px; margin-right:-15x" onclick="deletedetails(' + data + ')">Delete</a>'

                                 }
                             }
                        ],

                    })

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

                            e.stopPropagation();
                            var datalist;

                            var id = dataTable.row(this).data().Id;

                            $.ajax({
                                type: 'Post',
                                url: "/Details/ViewDetails/" + id + " ",
                                success: function (data) {

                                    FirstName.textContent = data[0].Firstname,
                                    LastName.textContent = data[0].LastName,
                                    Address.textContent = data[0].Address,
                                    DOB.textContent = data[0].DOBString,
                                    Email.textContent = data[0].Email,
                                    Phone.textContent = data[0].PhoneNo,
                                    SSN.textContent = data[0].SSN
                                }
                            })
                        });
                    } 
                
            });
        }) 

shown below is my edit table function

  function editdetails(id) {
            $('#Person').parsley().reset();
            $.ajax({
                url: "/Details/Edit/",
                type: "POST",
                data: JSON.stringify({ id: id }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var id = data[0].Id;
                    $('#id').val(data[0].Id),
                    $('#firstname').val(data[0].Firstname),
                    $("#lastname").val(data[0].LastName),
                    $('#address').val(data[0].Address),
                     $('#dob').val(data[0].DOBString),
                    $('#email').val(data[0].Email),
                      $('#phone').val(data[0].PhoneNo),
                    $('#ssn').val(data[0].SSN)
                }
            });
        } 

This question has accepted answers - jump to:

Answers

This discussion has been closed.