0

When using Select2-Bootstrap I register the event handler with the recommended declaration

$(document).ready(function(){
  $('.ctaskSelector').select2({
     theme: "classic"
  })
})

However if you dynamically add a Select element to the ctaskSelector class then the Select element is not bound to the new entity and the select box behaves as a default select element:

I have tried using Event Delegation which captures the events okay but the Select2 behaviour and features are not available. Does anyone have some pointers as to how I can resolve this?

  • 2
    You simply need to execute this line of code *after* you append the element. Event delegation isn't relevant to this problem – Rory McCrossan Apr 11 '18 at 13:11
  • Damn. I thought that was the solution but I was attempting to do it in a more complicated way. Many thanks! –  Apr 11 '18 at 13:15

0 Answers0