Created
December 14, 2011 06:01
-
-
Save taxilian/1475460 to your computer and use it in GitHub Desktop.
example of a select statement in an underscore template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<select name="formitem_school"> | |
<% if(schools && schools.length > 0) { | |
<option value="select_schools">Select School</option> | |
<% schools.each(function(t) { %> | |
<option value="<%= t.id %>" <% if(curSchool == t.id){ print('selected'); } %>><%= t.get("name") %></option> | |
<% }); | |
} else { %> | |
<option value"schools_none">No Schools</option> | |
<% } | |
</select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternatively:
<option value="<%= t.id %>" <%= curSchool === t.id ? 'selected' : void 0 } %> >