Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap popup when double click a table row

I'm have a bootstrap pop up box using this code.

<a class="btn btn-default" data-toggle="modal" data-target="#addModal"> test</a>

It is working without having any issue. Now I need to do the same(Appear the same pop up) when user double click on a table row which is in the same page. How can I do this?

like image 277
Asanka sanjaya Avatar asked Mar 18 '23 03:03

Asanka sanjaya


2 Answers

Try this code:

$('tr').on('dblclick', function() {
    $('#addModal').modal('show');
});

Since modal is already initialized by data attibutes on the button (data-target="#addModal"), you just need to bind dblclick event and show modal with .modal('show') method.

Demo: http://plnkr.co/edit/J0SuQdy00dcf9baE7xJu?p=preview

like image 79
dfsq Avatar answered Mar 29 '23 19:03

dfsq


This should work :) listen to double click and after that trigger modal manualy.

 $('.table-row').on('dblclick', function(){
       $('#addModal').modal('show')
    });

Source: http://getbootstrap.com/javascript/#modals

like image 31
Bob Avatar answered Mar 29 '23 19:03

Bob