Link in option in select 4.0.0

461 views
Skip to first unread message

serba...@gmail.com

unread,
Aug 9, 2015, 6:53:22 AM8/9/15
to select2
Hi guys,

Is there a way to add clickable links in the options? I saw that in previous versions there are ways to make this work but in version 4.0.0

http://stackoverflow.com/questions/15636302/attach-click-event-to-element-in-select2-result


Thanks

Kevin Brown

unread,
Aug 9, 2015, 9:46:29 AM8/9/15
to select2
The Stack Overflow answer you linked to uses a private method to detect when results were selected.

In past versions of Select2, all events (mousedown/mouseup/click/etc) were killed (propagation was stopped and default actions were prevented), which meant that you couldn't attach any event handlers to the results. In 4.0.0, this was changed so these events are not killed, but instead propagate their way up the DOM. This means that you can attach click handlers directly to elements now.


There is one caveat though, you are going to want to prefer the `mouseup` or `mousedown` handlers over the `click` handler. This is because Select2 destroys the dropdown on the `mouseup` event (which is why we prevent the propagation of it in the jsbin), and because of that any `click` handlers will not be triggered. A `click` handler can only be triggered if the element that it's being triggered on still exists, and by default it never will.

You can still use the `select2:select` event and use the `originalEvent` provided in the same way that the Stack Overflow answer used the old `onSelect` private method.

I just added a new answer to the question explaining most of this: http://stackoverflow.com/q/15636302/359284#31904887

--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.
To post to this group, send email to sel...@googlegroups.com.
Visit this group at http://groups.google.com/group/select2.
For more options, visit https://groups.google.com/d/optout.

serba...@gmail.com

unread,
Aug 9, 2015, 1:44:13 PM8/9/15
to select2, serba...@gmail.com
Works fine now! Thank you very much for the answer and your wonderful work!

Phill Jones

unread,
Nov 2, 2025, 1:02:39 PMNov 2
to select2
Spelling Bee Unlimited is a fun and challenging word game that helps sharpen vocabulary and spelling skills. I enjoy its variety of puzzles and timed rounds that keep every session exciting. It’s perfect for learners and word lovers who want a quick mental workout anywhere.

Luna lee

unread,
Nov 27, 2025, 10:31:21 AMNov 27
to select2
El juego de la serpiente de Google es un doodle simple y divertido que puedes disfrutar en línea en tu tiempo libre. Sus gráficos más recientes ofrecen una experiencia visual atractiva y moderna, haciendo que cada partida sea más entretenida. Es perfecto para relajarte y disfrutar de un momento de diversión rápida y adictiva.

Jamiejohn

unread,
Dec 9, 2025, 8:23:00 AM (6 days ago) Dec 9
to select2
The real value comes from resources that keep information organized and easy to check. Sites like how old is Sally Rychlak provide quick, updated details in one place, which makes it easier to verify info without digging through multiple sources.  

Emma Snow

unread,
Dec 11, 2025, 8:49:47 AM (4 days ago) Dec 11
to select2
ストップウォッチは、勉強タイマーとしても使える便利なツールです。運動や日常の作業だけでなく、集中して学習する時間の管理にも役立ちます。使い方も簡単で、スタート・ストップ・リセットの操作だけで手軽に計測できます。
Reply all
Reply to author
Forward
0 new messages