How to tell when a dynamically created element has rendered

前端 未结 7 1565
我在风中等你
我在风中等你 2020-12-02 12:54

I need to accurately measure the dimensions of text within my web app, which I am achieving by creating an element (with relevant CSS classes), setting its innerHTML

相关标签:
7条回答
  • 2020-12-02 13:43

    when you make for example

    var clonedForm = $('#empty_form_to_clone').clone(true)[0];
    
    var newForm = $(clonedForm).html().replace(/__prefix__/g, next_index_id_form);
    
    // next_index_id_form is just a integer 
    

    What am I doing here?
    I clone a element already rendered and change the html to be rendered.

    Next i append that text to a container.

    $('#container_id').append(newForm);
    

    The problem comes when i want to add a event handler to a button inside newForm, WELL, just use ready event.

    $(clonedForm).ready(function(event){
       addEventHandlerToFormButton();
    })
    

    I hope this help you.

    PS: Sorry for my English.

    0 讨论(0)
提交回复
热议问题