Created
June 23, 2015 13:39
-
-
Save anonymous/64372717ba83a551f768 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/qabumuvevo
This file contains hidden or 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> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<link href="http://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" rel="stylesheet" /> | |
</head> | |
<body> | |
<select style="width: 300px;" multiple="multiple"> | |
<!-- <optgroup label="Swedish Cars">--> | |
<option>red</option> | |
<option>green</option> | |
<!-- </optgroup> --> | |
<option>blue</option> | |
<option>yellow</option> | |
<option>white</option> | |
<option>black</option> | |
</select> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script> | |
<script id="jsbin-javascript"> | |
$("select").select2({ | |
closeOnSelect: false, | |
templateResult: function (data) { | |
var $res = $('<span></span>'); | |
var $check = $('<input type="checkbox" />'); | |
$res.text(data.text); | |
if (data.element) { | |
$res.prepend($check); | |
$check.prop('checked', data.element.selected); | |
} | |
return $res; | |
} | |
}); | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" rel="stylesheet" /> | |
</head> | |
<body> | |
<select style="width: 300px;" multiple="multiple"> | |
<\!-- <optgroup label="Swedish Cars">--> | |
<option>red</option> | |
<option>green</option> | |
<\!-- </optgroup> --> | |
<option>blue</option> | |
<option>yellow</option> | |
<option>white</option> | |
<option>black</option> | |
</select> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"><\/script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"><\/script> | |
</body> | |
</html></script> | |
<script id="jsbin-source-javascript" type="text/javascript">$("select").select2({ | |
closeOnSelect: false, | |
templateResult: function (data) { | |
var $res = $('<span></span>'); | |
var $check = $('<input type="checkbox" />'); | |
$res.text(data.text); | |
if (data.element) { | |
$res.prepend($check); | |
$check.prop('checked', data.element.selected); | |
} | |
return $res; | |
} | |
});</script></body> | |
</html> |
This file contains hidden or 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({ | |
closeOnSelect: false, | |
templateResult: function (data) { | |
var $res = $('<span></span>'); | |
var $check = $('<input type="checkbox" />'); | |
$res.text(data.text); | |
if (data.element) { | |
$res.prepend($check); | |
$check.prop('checked', data.element.selected); | |
} | |
return $res; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment