0

I'm using codeigniter and i've created a simple input with jquery ui autocomplete to show some results.

I'm just doing tests just to be sure that i could use this tool.

I've done this:

//in head
<script src="/js/jquery-1.9.1.js"></script>
<script src="/js/jquery-ui.js"></script>


//in body
<script type="text/javascript">
$(function() {

    var tags = [
    "ActionScript",
    "AppleScript",
    "Asp",
    "BASIC",
    "C",
    "C++",
    "Clojure",
    "COBOL",
    "ColdFusion",
    "Erlang",
    "Fortran",
    "Groovy",
    "Haskell",
    "Java",
    "JavaScript",
    "Lisp",
    "Perl",
    "PHP",
    "Python",
    "Ruby",
    "Scala",
    "Scheme"
    ];

    $("#autocomplete").autocomplete({
        source: tags
    });
});
</script>

<input id="autocomplete" />

but this is displaying no results!

In chrome dev tools -> network, i see that a request is done and is also getting status 200. So, why this is not displaying results?

In static blank html file with these lines, i'm getting the results!

thanks

2
  • Your code works fine: jsfiddle.net/MMRN9 What request are you talking about? You provided all data for you autocomplete on client side without any request. Show us example that represent exactly your situation. Commented May 6, 2013 at 18:16
  • This works, so it must be inside CI? Are you echoing something back? Commented May 7, 2013 at 14:23

1 Answer 1

1

HAve you added the CSS file for jQuery UI?

Add this in your <head> tag:

<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />

Also, If you've already included the CSS already but forgot to mention that in your question, Please replace

<script src="/js/jquery-1.9.1.js"></script>
<script src="/js/jquery-ui.js"></script>

with

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

I seriously doubt that the version of jquery and jQuery UI you are using are not compatible to each other.

Also, Please clean your browser cache before trying the above methods. :)

Edit:

Please make sure that you've declared the document type.

Put this before the <head> tag

<!DOCTYPE html>
Sign up to request clarification or add additional context in comments.

2 Comments

I've solved the problem removing $(function() { But i need to have this to call this onclick function.
when i click in a button, this create a input where i call autocomplete. I need to refresh DOM when i create the input or else when i try to use autocomplete in the input, nothing happens. So, i need to "refresh" dom when i click. onclick function

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.