In SPA I have a button. On clicking the button a dynamic form is created which uses select2. How to attach event to this dynamically created select2 element.
Due to small typo the event was not working. Now it is ok.
Hi!!
how did you solve the problem??
Thanks
Previously it was
$(’.dyn_cbox’).select2();
$(’#dyn_cbox’).select().on(‘select2:select’, on_select_cbox);
which I changed to
$(’.dyn_cbox’).select2();
$(’.dyn_cbox’).select().on(‘select2:select’, on_select_cbox);
and it worked.
…
function on_select_cbox(event)
{
console.log(event.params.data.id);
}
1 Like