Created
November 30, 2019 22:33
-
-
Save teomanofficial/02c5eb99e573a80e7f2eb57e83508ffa to your computer and use it in GitHub Desktop.
Common select2 examples
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
// load data by another event (on parent change) | |
$("#parent").on("change", function (e) { | |
$.ajax({ | |
url: '/api' + e.target.value, | |
dataType: "json", | |
success: function (data) { | |
$("#child").select2({ | |
data: data, | |
allowClear:true, | |
width: "100%", | |
disabled: !data.length | |
}) | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment