jquery-autocomplete

How to get the input element triggering the jQuery autocomplete widget?

血红的双手。 提交于 2019-11-29 16:32:49
问题 I have several input fields that are enhanced with jQuery auto-complete functionality. How to get the corresponding input field when a select event is triggered? <input name="1" value=""> <input name="2" value=""> <input name="3" value=""> $('input[type=text]').autocomplete({ source: 'suggestions.php', select: function(event, ui) { // here I need the input element that have triggered the event } }); 回答1: Try using $(this) $('input[type=text]').autocomplete({ source: 'suggestions.php', select:

Getting jQuery autocomplete to work with PHP source

你说的曾经没有我的故事 提交于 2019-11-29 15:47:22
I have a jQuery autocomplete field with this code: var tags = ["a", "ab", "abc", "abcd", "adbce", "abcdef", "abcdefg", "abcdefgh", "abcdefghi", "abcdefghij", "abcdefghijk", "abcdefghijkl", "abcdefghijklm", "abcdefghijklmn", "abcdefghijklmno", "abcdefghijklmnop", "abcdefghijklmnopq", "abcdefghijklmnopqr", "abcdefghijklmnopqrs", "abcdefghijklmnopqrst", ]; $("input#name").autocomplete({ position: { offset: "0 -10px", }, source: tags }); It worked correctly using the 'tags' array as sample input data. Now I need to have a set of MySQL query results instead of that sample array. What I did was

jquery autocomplete auto fill field with 1st value and highligh added part

怎甘沉沦 提交于 2019-11-29 13:03:23
问题 im using jqueryui autocomplete plugin with following code $(this).autocomplete({ source: function(request, response) { $.ajax({ url: 'clinic/auto', data: { 'term': this.term,'name': this.element.attr('complete')}, dataType: "json", type: "POST", success: function(data){ response(data); } }); }, minLength: 2 }); This display a list of all results in a dropdown. my question is how do i get it to autocomplete work for u and highlight the added part for easier use? do i have to code it ? or there

Javascript Autocomplete email's domain using jQuery UI

不问归期 提交于 2019-11-29 12:14:39
I need help, I am stuck with trying to make the following case scenario work: You have email input field, you type: foo@y - it should pop up autocomplete box, offering yahoo.com (for example). If you take this suggestion, the end value should become: foo@yahoo.com I have wrote this code (modified off another jquery UI sample): $( "#tags" ) // don't navigate away from the field on tab when selecting an item .bind( "keydown", function( event ) { if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) { event.preventDefault(); } }) .autocomplete({ minLength: 3,

Select first jquery UI result automatically

こ雲淡風輕ζ 提交于 2019-11-29 09:13:36
I am using jQuery Autocomplete to search a local database of cities. Here is the code: $('#txt_search_city').autocomplete({ source: url, delay: 0, autoFocus: true, select: function( event, ui ) { $( "#id_city" ).val( ui.item.id ); $(this).closest('form').submit(); }, focus: function( event, ui ) { event.preventDefault(); } }); I'd like the first returned value to be selected by default (like it works on facebook). So essentially, if they just hit enter they will trigger the selection of the first result. I thought that's what autoFocus: true did, but it isn't working. Not showing errors, just

How to filter your jquery autocomplete data while typing

不羁岁月 提交于 2019-11-29 02:42:29
So far I have the following var aCleanData = ['aaa','aab','faa','fff','ffb','fgh','mmm','maa']; $('#my-input').autocomplete({ source:aCleanData, minLength:2 }); Currently if you type aa , aaa,aab,faa,maa will show. What I would like to do is when the user types ff the data that is shown will be the fff,ffb data. Basically, only what is typed should be matched from the first character onwards. This should be recursive. When user types fg , fff,ffb should disapear and only fgh should appear. Thanks in advance for your help. UPDATE: p.s. See what I mean here: http://jqueryui.com/demos

How to get jQuery dropdown value onchange event

坚强是说给别人听的谎言 提交于 2019-11-28 15:27:00
问题 I have added two jQuery UI Dropdown Autocomplete script. Now I want get both value onchange of second dropdown and want to store separately in variable. How it is possible? Any ideas or suggestions? Thanks. My Fiddle: Sample My JS Code: (function($) { $.widget("ui.combobox", { _create: function() { var self = this, select = this.element.hide(), selected = select.children(":selected"), value = selected.val() ? selected.text() : ""; var input = this.input = $("<input>").insertAfter(select).val

jQuery UI autocomplete- no results message

萝らか妹 提交于 2019-11-28 13:16:36
I'm trying to have a "No Results" message appear in the dropdown menu if there are no results. So for instance, if I type in "ABCD" into the text field, and there is no entity that matches, the message "No Results." will be displayed. After looking through stackoverflow for the various different ways of accomplishing this, and trying a few of them, I still can't get it to work. How can I add a "No Results" message to the dropdown menu when no results are found? jQuery: $element.autocomplete({ source: function (request, response) { $.ajax({ url: thUrl + thQS, type: "get", dataType: "json",

Why I'm getting the jQuery error “TypeError: $(…).live is not a function ” in following scenario?

南楼画角 提交于 2019-11-28 11:58:04
Actually I'm trying to implement the autocomplete functionality to one text field but getting the above error, couldn't understand why I'm getting this error. Can you help me in resolving this error? For your reference I'm providing all the necessary code below: report-student-result.tpl <link rel="stylesheet" type="text/css" href="{$control_css_url}ui-lightness/jquery-ui-1.10.3.custom.css"> <link rel="stylesheet" type="text/css" href="{$control_css_url}autocomplete.css"> <label>Name</label> <div class="form-element" id="friends"> <input type="text" class="" name="user_name" id="user_name"

jQuery UI - Autocomplete generated inline style override?

守給你的承諾、 提交于 2019-11-28 10:43:14
问题 I'm using jQuery Autocomplete plugin which, generates following markup when suggestions show up. <ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all" role="listbox" aria-activedescendant="ui-active-menuitem" style="z-index: 16; width: 1355px; position: relative; top: -1615px; left: 40px; display: none; "> <li class="ui-menu-item" role="menuitem"> <a class="ui-corner-all" tabindex="-1">java</a> </li> <li class="ui-menu-item" role="menuitem"> <a class="ui-corner-all"