Attach click-event to element in .select2-result

后端 未结 12 1853
猫巷女王i
猫巷女王i 2020-11-29 02:06

I\'m looking for a way to attach a click-event to a select2-result-item. I\'ve gone ahead and formatted both result and selection via

function format(state)          


        
12条回答
  •  悲&欢浪女
    2020-11-29 02:37

    use default select2select event trigger instead of using other jquery events

    $('#mySelect2').on('select2:select', function (e) {
        var data = e.params.data;
        console.log(data);
    });
    

    for more details refer below link https://select2.org/programmatic-control/events

提交回复
热议问题