Reputation: 1061
I am using a Semantic Dropdown in one of my forms. I am adding the options using jinja2 as shown below.
<div class="ui selection dropdown">
<input type="hidden" name="set">
<i class="dropdown icon"></i>
<div class="default text">Class</div>
<div class="menu">
{% for set in sets %}
<div class="item" data-value="{{ set.id }}">{{ set.name }}</div>
{% endfor %}
</div>
</div>
I am trying to get the data-value
with javascript, and this is what I am currently using:
var setID = $('.ui.dropdown').dropdown('get value');
However when I use console.log(setID)
nothing is printed.
Any help would be appreciated
Upvotes: 1
Views: 456
Reputation: 1061
I found the problem: I had an if statement further down with 1 =
instead of two so it overwrote setID's value.
Upvotes: 1