Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
Bootstrap table buttons firing onlick multiple times

Global.Js file

function operativeEvents() {

    $('.tableButton').off().click(function (e) {

        var $this = $(this),
            tableId = $this.parents('table').attr('id'),
            $table = $('#' + tableId),
            index = $this.closest('tr').index(),
            data = $table.bootstrapTable('getData');

       //global variable to retrieve the data of the current row
        window.currentRow = data[index];

       buttonActions($this.attr('id'), $this.data('myid'));
    });

The operativeEvents function binds when the bootstrap table body is rendered. This is done with the onPostBody event. https://bootstrap-table.com/docs/api/events/

Local.cshtml This contains a switch case to handle the button clicks

        function buttonActions(id) {
            switch (id) {
                case 'bookButton':
                    bookMatch(currentRow.id);
                    break;
            }
        }

 function bookMatch(currentRow) {
            bootbox.dialog({
                message: '<h4 class="text-center">Are you sure?</h4>',
                buttons: {
                    cancel: {
                        label: 'Cancel',
                        className: "btn btn-danger"
                    },
                    confirm: {
                        label: 'Ok',
                        className: 'btn btn-success',
                        callback: function () {
                            alert('testing ' + currentRow);
                            return;
                            updateCall({
                                url: "/api/MatchesApi/BookMatch/" + currentRow.id,
                                tableRefresh: true,
                                serverSideMessaging: true,
                            });
                        }
                    }
                },
            });
        }

For some reason when I click the button it opens the Bootbox.dialog multiple times. I have tried using the off() method and also played around with event bubbling. Can someone please give me some advice? Thanks :)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!