Created
July 25, 2016 21:16
-
-
Save sendgrid-gists/3408c26ede3c1f8ed656a9646d1262fa to your computer and use it in GitHub Desktop.
SendGrid style-guide required select2
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
<div class="input-select-wrap is-required"> | |
<label class="input-select-label" for="select2-example-required">Sender</label> | |
<select id="select2-example-required"> | |
<option></option> | |
<option value="Jason">Jason</option> | |
<option value="Evan">Evan</option> | |
<option value="Katrina">Katrina</option> | |
<option value="Elena">Elena</option> | |
<option value="Katie">Katie</option> | |
<option value="Nate">Nate</option> | |
<option value="Felipe">Felipe</option> | |
<option value="Molly">Molly</option> | |
<option value="Dan">Dan</option> | |
<option value="David">David</option> | |
</select> | |
</div> |
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
$(function() { | |
$("#select2-example-required").select2({ | |
width: '100%', // sets inline width to 100% | |
minimumResultsForSearch: Infinity, // disables search | |
placeholder: "Select a sender", // show a placeholder | |
}).focus(function() { | |
$(this).select2('open'); // extend select2 to open on label focus | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment