treehouse : what would you like to learn today?
Web Design Web Development iOS Development

jQuery noob

  • ok here's the deal ive been working on this for days now and i know it will take you guys only 5 mins to solve my problem.
    basically im trying to make a search using http://docs.jquery.com/Plugins/Autocomp ... eplacement
  • so uhh, what is your problem exactly?
  • basically in the demo shown it is :

    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
    \"http://www.w3.org/TR/html4/loose.dtd\">
    <html>
    <head>
    <script src=\"http://code.jquery.com/jquery-latest.js\"></script>
    <link rel=\"stylesheet\" href=\"http://dev.jquery.com/view/trunk/plugins/autocomplete/demo/main.css\" type=\"text/css\" />
    <link rel=\"stylesheet\" href=\"http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.css\" type=\"text/css\" />
    <script type=\"text/javascript\" src=\"http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgiframe.min.js\"></script>
    <script type=\"text/javascript\" src=\"http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dimensions.js\"></script>
    <script type=\"text/javascript\" src=\"http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.js\"></script>
    <script>
    $(document).ready(function(){
    var data = \"Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities\".split(\" \");
    $(\"#example\").autocomplete(data);
    });
    </script>

    </head>
    <body>
    API Reference: <input id=\"example\" /> (try \"C\" or \"E\")
    </body>
    </html>


    and then i added the search feature (http://docs.jquery.com/Plugins/Autocomp ... eplacement)

    var data = [ {text:'Link A', url:'/page1'}, {text:'Link B', url: '/page2'} ];
    $(\"...\").autocomplete(data, {
    formatItem: function(item) {
    return item.text;
    }
    }).result(function(event, item) {
    location.href = item.url;
    });


    =


    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
    \"http://www.w3.org/TR/html4/loose.dtd\">
    <html>
    <head>
    <script src=\"http://code.jquery.com/jquery-latest.js\"></script>
    <link rel=\"stylesheet\" href=\"http://dev.jquery.com/view/trunk/plugins/autocomplete/demo/main.css\" type=\"text/css\" />
    <link rel=\"stylesheet\" href=\"http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.css\" type=\"text/css\" />
    <script type=\"text/javascript\" src=\"http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgiframe.min.js\"></script>
    <script type=\"text/javascript\" src=\"http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dimensions.js\"></script>
    <script type=\"text/javascript\" src=\"http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.js\"></script>
    <script>
    $(document).ready(function(){
    var data = [ {text:'Link A', url:'http://www.jquery.com/'}, {text:'Link B', url: 'http://docs.jquery.com/Plugins/Autocomplete#Search_Page_Replacement'} ];
    $(\"#example\").autocomplete(data);

    </script>

    </head>
    <body>
    API Reference: <input id=\"example\" /> (try \"C\" or \"E\")
    </body>
    </html>


    but when i type "link" or "jquery" nothing turns up
  • I've never played with that plugin before. I'll throw it on the list of things to play with though, that looks pretty neat. (Sorry I can't be of more help, I don't see anything at first glance)