Error: No select2/compat/inputData

15,412 views
Skip to first unread message

daddys...@gmail.com

unread,
Mar 23, 2015, 1:21:14 PM3/23/15
to sel...@googlegroups.com
Hi Guys,

I've been receiving the followin error when I try to do an ajax based options source.
Uncaught Error: No select2/compat/inputData
I can't seem to find any reference to it.

So i found this stack overflow example.

But continue to recieve the same error. (I thought it might be a pathing issue, but can't seem to resolve it, also I am not using any kind of server technology, jsut trying to call the json file directly as seen in the code below.) Am I missing something really obvious?


So, I tried changing to the CDN and received this error:
Uncaught ReferenceError: require is not defined

Project Structure:
root
--src
-----main
-------\webapp
-----------\json
--------------\select2_test.json
-----------\select2_test_ajax.html

Code that calls:

Select2_test_ajax.html:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<link href="resources/css/bootstrap.css">
<link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0-rc.2/css/select2.min.css" rel="stylesheet" />
</head>
<body>
<div class="row">
<form class="form">
<div class="form-group">
<input class='form-control col-lg-5 itemSearch' type='text' placeholder='select item' />
</div>
</form>
</div>
<script type="text/javascript" src="resources/js/jquery-2.1.3.js"></script>
<script type="text/javascript" src="resources/js/bootstrap.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0-rc.2/js/select2.min.js"></script>
<script>
$(document).ready(function(){
$(".itemSearch").select2({
placeholder: "Search for an Item",
minimumInputLength: 2,
ajax: {
url: "json/select2_test.json",
dataType: 'json',
type: "GET",
quietMillis: 50,
data: function (term) {
return {
term: term
};
},
results: function (data) {
return {
results: $.map(data, function (item) {
return {
text: item.completeName,
slug: item.slug,
id: item.id
}
})
};
}
}
});
});

</script>

</body>
</html>


select2_test.json:

[{"itemName":"Test item no. 1","id":5},
{"itemName":"Test item no. 2","id":6},
{"itemName":"Test item no. 3","id":7},
{"itemName":"Test item no. 4","id":8},
{"itemName":"Test item no. 5","id":9},
{"itemName":"Test item no. 6","id":10},
{"itemName":"Test item no. 7","id":11}]

Kevin Brown

unread,
Mar 25, 2015, 11:11:34 AM3/25/15
to sel...@googlegroups.com
Support for `<input />` tags is only available in the full builds of Select2. You should be using "select2.full.js" and we should be providing a better error message about it.

Kevin Brown


--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.
To post to this group, send email to sel...@googlegroups.com.
Visit this group at http://groups.google.com/group/select2.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages