Reputation: 1163
I am using jquery autocomplete in an amazon script in a joomla 3.2.2 install. jQuery calls are generated by joomla and the jquery easy plugin which is configured to add jquery 1.10.2 and jquery ui 1.10.3 and strip out any other instances (it appears to ignore the joomla added version).
Scripts are coming out like this:
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.css" type="text/css" />
<link rel="stylesheet" href="/foobar/media/sourcecoast/css/sc_bootstrap.css" type="text/css" />
<link rel="stylesheet" href="/foobar/cache/widgetkit/widgetkit-4d6b5675.css" type="text/css" />
<link rel="stylesheet" href="/foobar/media/sourcecoast/css/mod_sclogin.css" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.migrate/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script src="/foobar/plugins/system/jqueryeasy/jquerynoconflict.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js" type="text/javascript"></script>
<script src="/foobar/media/system/js/tabs-state.js" type="text/javascript"></script>
<script src="/foobar/media/jui/js/jquery.min.js" type="text/javascript"></script>
<script src="/foobar/media/jui/js/jquery-noconflict.js" type="text/javascript"></script>
<script src="/foobar/media/jui/js/jquery-migrate.min.js" type="text/javascript"></script>
<script src="/foobar/media/jui/js/bootstrap.min.js" type="text/javascript"></script>
The js that fails is:
jQuery(function () {
jQuery("#jform_itemtitle").autocomplete({
minLength: 3,
source: function (req, res) {
jQuery.ajax({
url: 'http://completion.amazon.com/search/complete',
cache: true,
dataType: 'jsonp',
data: {
'search-alias': 'aps',
'client': 'amazon-search-ui',
'mkt': '1',
'q': req.term
},
error: function (data) {
return false;
},
success: function (data) {
res(data[1]);
}
});
}
});
});
The error is:
Uncaught TypeError: Object [object Object] has no method 'autocomplete' in console and the autocomplete script does not work.
Upvotes: 0
Views: 357
Reputation: 1321
Put the below at the very top.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
And delete the below. Two version/includes can be dangerous:
<script src="/foobar/media/jui/js/jquery.min.js" type="text/javascript"></script>
Infact keep only 1 version. I'm seeing lots of js files are duplicate.
Upvotes: 2