Created
May 27, 2015 05:18
-
-
Save SilverFire/d875fc9732c6ff36ad38 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/cuzaxe
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> | |
<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> |
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
select { | |
width: 300px; | |
} |
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
$('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