How to add hyperlink or similar to a dropdown element?

142 views
Skip to first unread message

dowen....@gmail.com

unread,
Aug 10, 2015, 12:06:04 PM8/10/15
to select2
Hi all!


I'm not much of a JS expert, and am having trouble trying to find a way to allow the user to be linked to an external website (in the same window/tab) when a certain element inside the dropdown is clicked.

I did find a snippet of JS which adds text buttons to the dropdowns, however I cannot get this to work, and would still prefer the whole dropdown element to be a link.

Can anyone provide me with any support in achieving this please?


Thanks in advance!

Kevin Brown

unread,
Aug 10, 2015, 5:43:11 PM8/10/15
to select2
The following links might help you to get it working if you are looking to add a supplementary link to the dropdown


If you're looking to have your dropdown redirect the user to a different page when an option is selected, something like this might be better



--
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.

dowen....@gmail.com

unread,
Aug 11, 2015, 4:03:12 AM8/11/15
to select2, ke...@kevin-brown.com
Hi Kevin, thanks for this!

I think the latter option (redirect to different page) would be best, however my JS/JQ skills are so limited at the moment that its still causing me a little confusion!

dowen....@gmail.com

unread,
Aug 11, 2015, 7:10:34 AM8/11/15
to select2, ke...@kevin-brown.com, dowen....@gmail.com
Just an update. I had no idea what was causing this not to work for me. So my best option was to use the JS Bin snippet you provided and work the rest of my content around that, and now its working fine. So thanks for that!

dowen....@gmail.com

unread,
Aug 11, 2015, 7:23:41 AM8/11/15
to select2, ke...@kevin-brown.com, dowen....@gmail.com
Oh! One more thing. I want my event links to open in the same window. I've tried adding this myself but its failing. Could you please advise? Thanks!
Reply all
Reply to author
Forward
0 new messages