Created
June 15, 2015 00:41
-
-
Save cornernote/e6d1f3ce3f4983a73d89 to your computer and use it in GitHub Desktop.
select2 with free-text
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" rel="stylesheet"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script> | |
<title>Select 2</title> | |
</head> | |
<body> | |
<form> | |
<select id="e1"> | |
<option value="1">Awsome</option> | |
<option value="2">Cool</option> | |
<option value="3">Balls</option> | |
</select> | |
</form> | |
<script> | |
$('#e1').select2({ | |
multiple: false, | |
tags: true, | |
createTag: function (tag) { | |
return {id: tag.term, text: tag.term, tag: true}; | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment