|
|
|||||
Ajax Suggestions ScriptJAX Suggestions is pretty much what you might have seen with Google Suggest. The basic idea is, through AJAX, to give the user an immediate response to what they’re typing and displaying the search results their input would generate. AJAX Suggestions is an unobtrusive JavaScript to add that progressive enhancement to your web page, by the usage of two CSS class names to the desired input elements. It could also be used, for instance, in an online e-mail application where you would want to check a name in a global address book and return the related matches, with the possibility to then adding them to the field element. AJAX Suggestions is available either as stand-alone, or in conjunction with the DOMAssistant library. AJAX Suggestions is released under a Creative Commons Deed license. Basically, it means that it’s free to use and improve, and that the JavaScript files keep their reference to its creator. Like this: Copyright:
Then, just add two CSS classes to the input elements you want to add the AJAX Suggestions functionality to, ajax-suggestion and url-the-actual-URL, where you should replace the-actual-URL with your desired URL. The HTML code will look something like this:
It is also recommended to have the HTML code for the elements that will present the suggestions in your original HTML code. For example:
2 <h4>Top 5 results</h4> 3 <div id="search-results"></div> 4 </div> 5 Please note that AJAX Suggestions supports multiple elements in the same web page, who can also use different URLs for their AJAX calls. The same element is used for presenting the results, so it will only show you the results/suggestions for the latest search.
2 <li><a href="1" class="item">Suggestion #1</a></li> 3 <li><a href="2" class="item">Suggestion #2</a></li> 4 <li><a href="3" class="item">Suggestion #3</a></li> 5 <li><a href="4" class="item">Suggestion #4</a></li> 6 <li><a href="5" class="item">Suggestion #5</a></li> 7 </ul> 8 <p><a href="/" class="item"><b>Search for all items</b></a></p> 9 Settings AJAX Suggestions gives you a number of settings for you to get the most out of your usage. The different settings, available at the top of the ajaxSuggestions JavaScript file, are described below. Here are the default settings:
02 elmIdResultsContainer : "search-result-suggestions", 03 charactersBeforeSearch : 2, 04 timeBeforeSuggest : 200, // In milliseconds 05 sameWidthAsInputElm : false, 06 offsetLeft: 0, 07 offsetTop : 0, 08 urlExt : "search=", 09 addSearchTermToQueryString : true, 10 addKeyNavigationEvents : true, 11 hideResultsOnDocumentClick : true, 12 itemClassName : "item", 13 itemSelectedClassName : "selected", 14 itemInsertValueIntoInputClassName : "choose-value", 15 itemInsertValueSetFocusToInput : true, 16 hideResultsWhenInsertValueIsSelected : true, 17 itemSeparator : ";", 18 turnAutoCompleteOff : true, source: ajaxupdates |
|||||
| Copyrights Reserved AjaxProjects.com 2006-2013, Powered by Enozom - Mobile Development Company -Privacy Policy |