Initializing a dropdown using HTML

1,304 views
Skip to first unread message

William Shea

unread,
Apr 5, 2014, 11:52:15 PM4/5/14
to seman...@googlegroups.com
I have copied the html dropdown example from semantic-ui documentation but it doesn't seem to initialize itself.

<div class="ui dropdown">
  <div class="text">Select</div>
  <i class="dropdown icon"></i>
  <div class="menu">
    <div class="item" data-value="option1">Option 1</div>
    <div class="item" data-value="option2">Option 2</div>
  </div>
</div>

Do I have to use javascript to initialize it? Thanks.

Grady Kelly

unread,
Apr 9, 2014, 5:54:23 PM4/9/14
to seman...@googlegroups.com
Would love to know this answer too. I took the example from the docs and added menu.js

What else is needed to make a menu workie?

I have noticed this with a lot of the examples. Would be great to have some simple cut and paste all in one examples that just work.

Grady

Grady Kelly

unread,
Apr 9, 2014, 6:13:47 PM4/9/14
to seman...@googlegroups.com
I figured this out. You need to add this:

<script type='text/javascript'>//<![CDATA[ 

$(document).ready(function() {
    $(function () {
            $('.ui.dropdown').dropdown();
        });
});
//]]>  

</script>

William Shea

unread,
Apr 11, 2014, 2:25:17 AM4/11/14
to seman...@googlegroups.com
Thank you very much for your answer.

Having embedded javascript in HTML is kind of defeat the object of "HTML only" dropdown menu though.... just wonder is there anyway to implement which is really javascript-free?


Grady Kelly於 2014年4月10日星期四UTC+8上午6時13分47秒寫道:

Jack Lukic

unread,
Apr 11, 2014, 7:37:36 AM4/11/14
to William Shea, seman...@googlegroups.com
"ui simple dropdown menu" will open on :hover without js

Sent from my iPhone

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

William Shea

unread,
Apr 11, 2014, 7:49:43 AM4/11/14
to seman...@googlegroups.com, William Shea
That's what I thought how it is supposed to behave, but it doesn't open on hover.


Jack Lukic於 2014年4月11日星期五UTC+8下午7時37分36秒寫道:

Jack Lukic

unread,
Apr 11, 2014, 9:31:51 AM4/11/14
to William Shea, seman...@googlegroups.com
Here is an example:

Variations are types of an element, you must include "simple dropdown" to have dropdown function without javascript.

William Shea

unread,
Apr 13, 2014, 2:51:58 AM4/13/14
to seman...@googlegroups.com, William Shea
It works now! Thanks.

Jack Lukic於 2014年4月11日星期五UTC+8下午9時31分51秒寫道:

dan.e...@gmail.com

unread,
Nov 29, 2016, 1:46:48 AM11/29/16
to Semantic UI
Hi, just a quick question, what language is this?

I attempted to stick that patch of script into my header file and my browser is complaining that it can't read the $.
Reply all
Reply to author
Forward
0 new messages