Reply To: clone a row with dropdown – and new dropdown becomes un clickable

#10033630
Support
Keymaster

Hello Pelle,

Oh, right!

Please try with this new code:

$(document).on('click', '.add-more', function () {          
    // TR ROW HTML
    var row_to_append = '<tr>' + 
        '<td><input type="text" name="id[]" class="form-control"></td>' + 
        '<td>' + 
           '<select name="contents[]" data-plugin-selectTwo class="form-control populate" style="width: 100%;">' + 
                '<option value="0">-- välj bedömning --</option>' + 
                '<option value="1">Felaktig</option>' + 
                '<option value="2">Kräver reparation</option>' + 
                '<option value="3">Ingen åtgärd</option>' + 
            '</select></td>' + 
        '<td><input type="text" name="Brist[]" class="form-control"></td>' + 
        '<td>' + 
            '<div class="input-group">' + 
                '<span class="input-group-btn">' + 
                    '<button onclick="javascript:void(0);" id="addMore" class="add-more adding btn btn-light btn-pluss" type="button">+</button>' + 
                '</span>' + 
                '<span class="input-group-btn pl-1">' + 
                    '<button onclick="javascript:void(0);" class="remove btn btn-light btn-minuse" type="button">-</button>' + 
                '</span>' + 
            '</div>' + 
        '</td>' + 
    '</tr>';

    $("#tb").append( row_to_append );

    // Initialize the new select
	$("#tb tr:last-child").find( 'select' ).select2({
		theme: 'bootstrap'
	});
});

And change the HTML of add more button to:

<button onclick="javascript:void(0);" id="addMore" class="add-more adding btn btn-light btn-pluss" type="button">+</button>

We hope this helps!

kind Regards,

Rodrigo.


If you are satisfied with Porto Admin and our support, please leave your comment and rating on ThemeForest downloads page. That helps us a lot: https://themeforest.net/downloads