Attach click-event to element in .select2-result

后端 未结 12 1821
猫巷女王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:25

    Because Select2 lib prevent any click events on popover list you can't bind events to .info directly. But you can redefine onSelect method and place there any code you want.

    See example: http://jsfiddle.net/f8q2by55/

    Update for multiple selects: http://jsfiddle.net/6jaodjzq/

提交回复
热议问题