0

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.

1
  • 1
    You are including jQuery twice. The second inclusion overwrites the first one. Commented Feb 20, 2014 at 17:03

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks - that fixed it. I thought jquery easy was supposed to strip the native joomla instances of jquery and jquery ui, but it doesn't seem to do that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.