I've been using Bootstrap-3 with modals for the past couple of months. And it's the first time I've experience this problem. Since I want to show content when an option in a select is changed, I'm using the change function that Jquery provides. The problem here is that when I'm using this code in the modal, it triggers fine, and it closes and I open it again, the value of the select multiplies the times I have openned and closes. Example, if the value is 1, in the first time, and I close it, when I open it again, and change it to 2, it goes like this with the console.log: 1 2 2 And so on.

I've tried using the off method when the modal closes, but when I open the modal again the on method doesn't do anything.

$(".edit_data").on('click', function(){    
    var employee_id = $(this).attr("id"); 
  var periodo = null; 

      var usuario = data.id_usuario;

        periodo = $('select[name=periodo_e]').val();   
        url: "url.php?id="+usuario+"&periodo="+periodo
        }).done(function(data) { // data what is sent back by the php page
        $('#evaluadoss').html(data); // display data

$('#myModalEvaluacion').on('hidden.bs.modal', function () {


The problem persist when I'm doing the select option. It multiplies the values and goes crazy with the result that I want.

I expect the code not to multiply the result, since I'm opening and closing the modal, the id of the employee won't coincide with the employee id that displays in the change method.

0 Answers