Template: Why is my select without options when using within a template?

Template: Why is my select without options when using within a template?

CRogozaCRogoza Posts: 5Questions: 2Answers: 0
edited March 2020 in Free community support

I have a select field within a template.
<select id="manufacturerSelect"></select>
It is filled using ajax within the initComplete of my datatable:

initComplete: function() {
            table.buttons().container().appendTo( $('.col-md-6:eq(0)', table.table().container() ) );               
            $.ajax({
                url: 'ajax/manufacturer',
                success:function(data){
                    $.each(data, function(key, obj){
                        var option = new Option(obj.Title, obj.IDManufacturer);
                        $(option).html(obj.Title);
                        $("#manufacturerSelect").append(option);
                    });
                }
            });
        }

That works fine and my select is filled as long as I do not use the template for the editor. When using the template for the editor an hit "New" the templates opens fine, but my select is empty.

Answers

  • CRogozaCRogoza Posts: 5Questions: 2Answers: 0

    Solved it.
    I moved the $.ajax that fills my <select> into:

    editor.on( 'open', function () {
    });
    
This discussion has been closed.