Skip to content

Instantly share code, notes, and snippets.

@SilverFire
Created May 27, 2015 05:18
Show Gist options
  • Save SilverFire/d875fc9732c6ff36ad38 to your computer and use it in GitHub Desktop.
Save SilverFire/d875fc9732c6ff36ad38 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/cuzaxe
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://select2.github.io/dist/js/select2.full.js"></script>
<meta charset="utf-8">
<link rel="stylesheet" href="http://select2.github.io/dist/css/select2.min.css">
<title>JS Bin</title>
<style id="jsbin-css">
select {
width: 300px;
}
</style>
</head>
<body>
<select data-module="test" />
<div class="out"></div>
<script id="jsbin-javascript">
$('select').select2({
ajax: {
url: 'example.com',
data: function (param) {
console.log(param, this);
return {results: {
q: param.term,
module: $(this).data('module')
}};
}
}
});
</script>
<script id="jsbin-source-css" type="text/css">select {
width: 300px;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">$('select').select2({
ajax: {
url: 'example.com',
data: function (param) {
console.log(param, this);
return {results: {
q: param.term,
module: $(this).data('module')
}};
}
}
});</script></body>
</html>
select {
width: 300px;
}
$('select').select2({
ajax: {
url: 'example.com',
data: function (param) {
console.log(param, this);
return {results: {
q: param.term,
module: $(this).data('module')
}};
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment