I am using Select2, I would appreciate it in advance if you could help me with the following problem. I have a table where I add elements of type <select> using a button.

enter image description here

I am starting the Select2 plugin as follows:

    $(document).ready(function() {

After that .. I want to delegate an event so that every time I create a new <select>, I add a new array to that element with the data I want to list.

I have tried it as follows:

$(document).on('select2:opening', 'select[name^="table"]', function(e) {
  var data = [
        id: 0,
        text: 'enhancement'
        id: 1,
        text: 'bug'
        id: 2,
        text: 'duplicate'
        id: 3,
        text: 'invalid'
        id: 4,
        text: 'wontfix'

    data: data

When I verify, in the browser console I get the following error:

TypeError: this.dataAdapter is null

I read in the following URLs but I can't find any solution in any of them for my mistake:

jquery select2: TypeError: b.dataAdapter is null3


Please I would appreciate in advance if someone could help me with this problem.

0 Answers