Skip to content

Instantly share code, notes, and snippets.

@teomanofficial
Created November 30, 2019 22:33
Show Gist options
  • Save teomanofficial/02c5eb99e573a80e7f2eb57e83508ffa to your computer and use it in GitHub Desktop.
Save teomanofficial/02c5eb99e573a80e7f2eb57e83508ffa to your computer and use it in GitHub Desktop.
Common select2 examples
// 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