Modal does not work after load div

1

Well, my problem is, I have a function in an external file

function lista_contas(id) {
    var url = 'lista_dados.php';
    var method = 'POST';
    var params = 'id='+id;
    params += '&select_ano='+document.getElementById('select_ano').value;
    var container_id = 'list_container' ;
    var loading_text = '<div class="span12 responsive" data-tablet="span12 fix-offset" data-desktop="span12" style="margin:0 auto"><img src="img/load.gif"></div>' ;
    // call ajax function
    ajax (url, method, params, container_id, loading_text) ;
}

I call it an onclick, within the div list_container are loaded a tables, which have links to modal, these modal are not opening after the onclick. I call the manners like this:

$('#finaliza_conta').on('show', function() {
    var id = $(this).data('id');
});

$('.conta_finaliza').on('click', function(e) {
    e.preventDefault();

    var id = $(this).data('id');
    document.getElementById('id_conta').value =  id;
    $('#finaliza_conta').data('id', id).modal('show');
});

Note: Modes bootstrap 2.3.2

Is it because the page lista_dados.php, is not loading files related to modal?

    
asked by anonymous 02.06.2015 / 20:08

1 answer

1

Try to use:

$('#list_container').on('click', '.conta_finaliza', function(e) {
   e.preventDefault();
   var id = $(this).data('id');
   document.getElementById('id_conta').value =  id;
   $('#finaliza_conta').data('id', id).modal('show');
});

If I understand correctly elements with class .conta_finaliza are created dynamically. To be able to define events in them it is necessary to associate the event with a parent element.

    
02.06.2015 / 21:34