Call select2 with own data

function printResult(response) {
t = templateMarkup(JSON.parse(response));
document.getElementById("productform").select2({
    templateResult: templateMarkup,
    templateSelection: templateMarkup,
    escapeMarkup: function(m) { return m; },
    text: t,
  })
}

Any hint what’s my mistake, that causes “select2 is not a function”? The library is being loaded…