'Select2 element not behaving correctly
So I’m using the select2 library for my drop down search list now my issue is that it’s not actually letting me select any of the options and no tutorial is able to help me do what I need to do. Which is when I click on the drop down box and find the option I want, once I click that option it should display in that drop down box.
This is what I have code wise so far:
<select id=“select_field”>
<?php
foreach($options[‘values’] as $option){
echo ‘<option value=“‘.$option[‘id’].’”>’.$option[‘name’].’</option>’;
}
?>
</select>
<script type=“text/javascript”>
$(document).ready(function(){
$(‘#select_field).select2({});
});
</script>
So I’m not sure what exactly I’m missing to make the option selectable? Any help will be appreciated and I know the speech marks are wrong but I’m writing this up on my ipad
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
