[jQuery] Re: event handlers that run after the browser's default action
i was interested in using the value of a text input immediately after the browser has finished handling a keyboard event. On 8/21/09 10:14 AM, "ak732" wrote: > > Not sure that there's a more deterministic approach - if so, it's > beyond my limited Javascript knowledge. > > Specifically what are you trying to accomplish by wiring an event > handler to fire after the default action? > > On Aug 20, 10:39 pm, Tom Worster wrote: >> thanks. >> >> i thought of using a timeout and it could probably be made to work fairly >> well. but i'd be left with the worry that some user's crummy old browser and >> computer that's too busy doing other things might need a longer delay than i >> set. >> >> we can insert event handlers at the beginning of the event propagation >> chain. or catch the event later as it bubbles. but i've never heard of >> attaching a handler to the chain after the browser has done its bit. i was >> wondering if this was just my ignorance or if it just can't be done that >> way. >> >> On 8/20/09 8:45 PM, "ak732" wrote: >> >> >> >>> This is crude, but might work for you... >> >>> $("#someId").click()(function() { >>> set_timeout(function() { >>> // stuff to be done 2ms from now >>> }, 2); >>> }); >> >>> You might have to play with the set_timeout delay a bit, 2ms might be >>> too short. >> >>> On Aug 20, 3:47 pm, Tom Worster wrote: >>>> is there a way to set up a page so that a event handler function is bound >>>> to >>>> a DOM object and event but it runs _after_ the browser's default action is >>>> complete?
[jQuery] Re: event handlers that run after the browser's default action
thanks. i thought of using a timeout and it could probably be made to work fairly well. but i'd be left with the worry that some user's crummy old browser and computer that's too busy doing other things might need a longer delay than i set. we can insert event handlers at the beginning of the event propagation chain. or catch the event later as it bubbles. but i've never heard of attaching a handler to the chain after the browser has done its bit. i was wondering if this was just my ignorance or if it just can't be done that way. On 8/20/09 8:45 PM, "ak732" wrote: > > This is crude, but might work for you... > > $("#someId").click()(function() { > set_timeout(function() { > // stuff to be done 2ms from now > }, 2); > }); > > You might have to play with the set_timeout delay a bit, 2ms might be > too short. > > On Aug 20, 3:47 pm, Tom Worster wrote: >> is there a way to set up a page so that a event handler function is bound to >> a DOM object and event but it runs _after_ the browser's default action is >> complete?
[jQuery] event handlers that run after the browser's default action
is there a way to set up a page so that a event handler function is bound to a DOM object and event but it runs _after_ the browser's default action is complete?
[jQuery] time entry controls (e.g. timeEntry plugin)
does anyone use a jquery time entry control? which one? i'm looking at this one: http://keith-wood.name/timeEntry.html which seems ok. i'd be interested to know what others are using and what you think of them.
[jQuery] Re: [Autocomplete] Form submit or link on mouse click or return key
On 7/20/09 1:06 PM, "koichirose" wrote: > Hello, I'm using jQuery Autocomplete ( > http://docs.jquery.com/Plugins/Autocomplete > ) to display results from a php page. > > Since that is my only field, I want to submit the form when I click on > the result or I press the 'return' key. > > How do I do that? > > The result is showing something like 'artist - album' and I'd like to > post only the artist . > > Also, it would be event better without a form submit: the results > would have their own php-generated link to another php page with > artist passed as a $_GET variable. I click or press enter on them and > it would work just like a link. > > Is there a way to achieve that, either by submitting the form or by > linking to the new php page? take a look at result() documented on the page you liked above. you should be able to program the functionality you want in a result() handler.
[jQuery] Re: Autocomplete - finding out (on blur) if the user has picked an item from the list or not
On 7/2/09 5:49 AM, "gnjunge" wrote: > Concerning Jörn Zaefferer autocomplete. > > In many cases the autocomplete list is being filled with Key Value > pairs, such as a list of FooBars with their name and id. Using the > result function one would get the id, and drop it into a hidden field. > > I want to allow users to either pick an existing FooBars from the > list, or enter a new one if he cannot find a suitable one. But for > that to work I need to know that the autocomplete box contains a > custom item, with other words: an item that was not in the list. > > The result event is only triggered whenever an item was picked from > the list. > > How would I go about implementing this. My starting point was to add > code to the "blur" event of the autocomplete, yet I can't get enough > information to see if the currentValue is from the list, or a custom > entry. what i did was add a flag in the input's .data() called 'chosen'. i set the flag in the input's .result() handler. i clear it on .change(), or on .focus() if the input's value is an empty string. the flag can be read whenever to determine if the value in the field is chosen from the suggestions or typed.
[jQuery] Re: howto: using autocomplete and validate (with remote) together
On 6/30/09 9:03 AM, "hobbesdev" wrote: > > hi, > > i have in input element where the user can enter multiple email > addresses (like in thunderbirds to: field) > i use autocomplete to make suggestions form the database when the user > enters new adresses. > then i want to validate the emailadresses before sending the email, > because the user can add email addresses by 1.) lookup or 2 manual editing > so i used validate with > > var validator = $j("#werkeForm").validate({ > rules: { > empfaenger:{ > required: true, > minlength:2, > remote: "ajaxserver2.php?cmd=chkEmail" > }, > > > now the problem seems to be a kind of race condition, cause both methods > try to operate on the input field. > > firebug shows me that each method takes only a few milliseconds, but > combined they take up to 3 secondes after every keystroke. > > is there any advice on how to combine these both plugins? could you try invoking the undocumented method .unautocomplete() before invoking validate()? i don't know how fancy your validation is but with fancy autocompletion happening it might be easier on the user if email address validation only happens on form submit. that approach would allow you to turn off autocompletion before doing any validation.
[jQuery] Re: [autocomplete][livequery] .change()
On 6/26/09 11:14 AM, "lazytt" wrote: > > Hello. I'm having a problem with the following code: > > $(".prodname").livequery(function(){ $(this).autocomplete > ("search.php", { > extraParams: { 'type':'products' } > }); }); > > $(".prodname").livequery(function(e){ $(this).change(function(e) { > $(".barcode."+thisline(e)).val(''); > $.ajax({ > type: "GET", > url: "agent.php", > data: "prodname="+$(".prodname."+thisline(e)).val() > +"&action=getprodid", > success: function(text){ > $(".prodid."+thisline(e)).val(text); > } > }); > }); }); > > It seems that the change event doesn't auto-bind to new elements. i wouldn't expect so. adding an element to the dom isn't an onChange event. > If I > use .click() it works fine. If I remove the auto complete it works > fine. And the .change() gets triggered just fine on static elements - > the problem is only on new (ajaxly added)elements. what i do to add a autocomplete to new, ajax-added dom elements is: $(window).ajaxStop(function() { ... code to add autocompletes here ... });
[jQuery] Re: JQuery Autocomplete - conditional autocompletion between fields
to set extraParams dynamically to the current value of other dom elements, assign a function to the extraParams that retrieves the value from the dom, e.g. $("#state").autocomplete(url, { extraParams: { town: function() { return $("#town").val(); } } }); see http://docs.jquery.com/Plugins/Autocomplete#Dependencies_between_fields alternatively, you can assign a static value, that of the input then the autocomplete() method was involked (probably at page steup time), using MorningZ's code quoted below. now, to address your other question, if you also have: $("#town").autocomplete(url, { extraParams: { state: function() { return $("#state").val(); } } }); then your backend at url can infer which input the user is typing into from the GET parameter names sent. but if you want, you could add another static parameter to explicitly say what is being sent in the q parameter rather than inferring from the other parameter names, e.g.: $("#state").autocomplete(url, { extraParams: { qis: 'state', town: function() { return $("#town").val(); } } }); $("#town").autocomplete(url, { extraParams: { qis: 'town', state: function() { return $("#state").val(); } } }); On 6/28/09 3:23 PM, "MorningZ" wrote: > > Use AutoComplete's "extraParams" hook > > http://docs.jquery.com/Plugins/Autocomplete/autocomplete#toptions > > so it would be like: > > $("your state search textbox").autocomplete( > "/ajax/location.php", > { extraParams: { type: $("#state").val() } } > ); > > > > On Jun 26, 12:34 pm, 01101010001010001010 > wrote: >> Hi, >> >> First of all, thanks for the autocomplete code - it's excellent. >> Apologies if this next question is too simple, but I couldn't get the >> answer on google (lmgtfy.com) >> >> I have two autocomplete fields, for address-matching, which for the >> sake of argument could be called state and town. >> >> I have autocomplete on state go to /ajax/location.php?type=state and >> autocomplete on town go to /ajax/location.php?type=town >> >> My location.php script works fine delivering autocomplete results for >> each field individually. >> >> I want to pass the contents of ${#state} to the script when >> autocompleting town (so it will only autocomplete for towns in the >> already-chosen state). >> >> I can't see how to tell autocomplete to pass ${#state}.val in the call >> for town. >> >> Any thoughts gratefully received - and thanks again for the brilliant >> code. >> >> Peter
[jQuery] Re: ajax load
On 6/27/09 11:15 AM, "Peter Marino" wrote: > when I use the $(".main_view").load( "my.php" ); > all my danish letters are rendered wrong. > is there something I need to do in the my.php to make sure it > shows the danish characters correctly? > > anyone? perhaps my.php is returning the text encoded using a different character encoding from the page it's being loaded into. for example, say we have a page that's encoded as iso-8859-1, the server says that's the encoding and the user agent understands and displays it nicely. then, via ajax and js, utf-8-encoded text is retrieved from the server and inserted into the page's dom. i would expect the user agent to render the text as though it were iso-8859-1 and that would be a problem. i've never tried it but i'd be surprised if the user agent would notice the mismatch and perform a conversion. there could be other explanations but this is worth checking.
[jQuery] Re: Autosuggest based dropdown selection plugin
On 6/27/09 5:11 AM, "bharani kumar" wrote: > Hi all , > I used the auto suggest / complete in my lot of projects , > > > But this is some what different , > > I need the auto suggest plugin , that auto suggest > must work based on the dropdown selection , > > Assume if select the airport , the airports data only populate or show in > the suggest , not an alll , > > -- Autosuggest airport seaport stations how about putting the value of the select in extraParams and then have your backend for the usual autocomplete plugin return only relevant suggestions?
[jQuery] Re: Autocomplete Behavior clarification
On 6/10/09 1:17 PM, "Brad" wrote: > > I have an Autocomplete on a form that uses local data. However, the > input allows users to enter values that are not in the local data > array. If the user enters and selects matching data the .result > callback function sets a corresponding key value that is submitted > with the form. The intent is to help enter known values, but others > are allowed. > > What I'm observing is that if a match is entered, the corresponding > key will be set. But if the user further edits the matched value the > autocomplete doesn't fire again. This creates a problem because the > key never changes. Is that expected autocomplete behavior? If so, is > there a workaround? > > Here's the code: > > $("#calibration_location_name").autocomplete( locations, { > minChars: 0, > width: 310, > selectFirst: false, > scroll: true, > matchContains: "word", > mustMatch: false, > autoFill: false, > formatItem: function(row, i, max) { > return row.name; > }, > formatMatch: function(row, i, max) { > return row.name; > }, > formatResult: function(row) { > return row.name; > } > }) > .result(LocationAutoCompleteCallback) > .blur( function(){ > if($(this).val() === '') { > $("#calibration_locationkey").val(0); > } > }); i'm not sure i understand your problem entirely but my guess is that the formatX methods aren't necessarily the right solution for your problem. if what you want is to submit the key associated with the string in the input if and only if one exists in your array then you could perhaps do the key lookup at form submit time quite independently of the autocompletion plugin.
[jQuery] Re: autocomplete
On 6/10/09 1:11 AM, "smiling_face" wrote: > > first of all thanks for your gr8 plugins to add autocomplete feature > using jquery. but I am facing a problem to implement this in my > application. As in error console it is showing > syntext error > .ac_results { > > > and showing the list of probables as simple ul viwe (with bullets) > plz suggest me further. > > I am using Revision: $Id: jquery.autocomplete.js 5747 2008-06-25 > 18:30:55Z are you using the stylesheet that comes with the plugin?
[jQuery] Re: autocomplete
On 6/5/09 3:37 AM, "BBCLX" wrote: > I am using the plugin in "remote-mode" meaning that I fetch a > seperated list from my server. The problem now is that this server > uses basic authentication and whenever I start typing I get prompted > for the username and password, which is quite annoying. > > The jQuery Form Plugin for example allows to send username and > password for authentication, which are in fact plain $.ajax > parameters. Is such a method possible for the autocomplete plugin as > well or how could I possibly work around this problem? not for "basic auth" which is handled in http. you need to fix this on the server. i don't think there's much point in user auth for autocompletion lookups so i would turn it off.
[jQuery] Re: [autocomplete] hard time with accent
On 6/4/09 2:17 PM, "James" wrote: > What are you using to do the string matching? depends on the kind of search i need. > For me, I was using autocomplete to search for something stored in a > MySQL database, i think that's a very common scenario. > and MySQL by default automatically matches even those > strings with accents from non-accented characters. according to collation. > It should either be > the script or the database that handles this conversion/matching. if by "script" you mean client script then i can't agree. say i wanted more than a simple search, i want exact matches frist, then prefix matches in lexical order, and finally fuzzy matches in Damerau-Levenshtein order with lexical suborder. the right place for much of that work is in the backend script. btw: if you use a php backend then converting character encodings is very easy.
[jQuery] Re: [autocomplete] hard time with accent
On 6/3/09 11:55 PM, "Gustavo Salomé" wrote: > No way you can do this unless you do have 'switch' that converts all > elements to its respective non-utf8 code. how is the search string encoded in the q parameter sent to the backend? whatever conversion is needed, isn't it easier to do in the backend than in client js? > 2009/6/2 Tom Worster > >> >> On 6/1/09 2:48 PM, "Gui" wrote: >> >>> I'm currently using this JQuery autocomplete plugin. It fits my needs, >>> pretty cool, however I'm having a hard time with accents. If I type: >>> Antonio, the plugin won't retrieve Antônio. I mean, it won't handle >>> the special characters (á, à, é, í, ó, ú and so on.) >>> >>> Is there any option so that it can handle them? >> >> for the local database, i'm not aware of one. if you're using ajax and >> remote back end then maybe you can handle this in your script. if using >> mysql backend, perhaps setting a different collation and tweaking your >> query >> is all you need. >> >> >> >
[jQuery] Re: [autocomplete] - Problem closing autocomplete
On 6/3/09 10:49 AM, "AlexKV" wrote: > If the Autocompleter ist active and I click somewhere else on the page > to close the autocompleter, the autocompleter inputbox will be > focused. Can I change this behavior? I want that the autocompleter > will be closed if I click somewhere and that the clicked element will > be focused. > The examples on the Demopages have the same behavior. it's annoying, isn't it? i tried to sort it out and failed. if you find a solution, please post it here.
[jQuery] Re: [autocomplete] hard time with accent
On 6/1/09 2:48 PM, "Gui" wrote: > I'm currently using this JQuery autocomplete plugin. It fits my needs, > pretty cool, however I'm having a hard time with accents. If I type: > Antonio, the plugin won't retrieve Antônio. I mean, it won't handle > the special characters (á, à, é, í, ó, ú and so on.) > > Is there any option so that it can handle them? for the local database, i'm not aware of one. if you're using ajax and remote back end then maybe you can handle this in your script. if using mysql backend, perhaps setting a different collation and tweaking your query is all you need.
[jQuery] Re: browser detection, conditional CSS
On 6/1/09 1:16 PM, "waseem sabjee" wrote: > i good thing to do is to declare this styles on your default / index page > /* > keep your page defaults the same across each browser > */ > html { > width:100%; > height:100%; > } > /* > declare the initial margin and padding of each element to be 0, 0 > */ > * { > margin:0; > padding:0; > } this principle is sound, though i had trouble with resetting * and now use the following default reset: html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin:0; padding:0; outline:0; font-size:1em; } > On Mon, Jun 1, 2009 at 6:44 PM, Adam wrote: > >> >> What's everyone's opinion on current best-practice for offering >> conditional CSS for specific browsers. I just noticed that Jquery used >> to have a detection function rolled in, which was deprecated. I have >> been using IE conditional comments to do this for a long while but >> recently used a WP theme (Justin Tadlock's hybrid) that used http user >> agent to add classes to the body tag depending on which browser and I >> sorta liked this approach. Mostly because it actually works in my PC >> testing enviro. Thoughts? Thanks everyone! i gave up on browser specific css. i couldn't find a way to do it that wasn't risky one way or another. when i really need different stylings, i will use ie conditional html to make the markup different for different browsers and then use standard css without hacks. btw: was this a jquery question?
[jQuery] Re: [autocomplete] matchContains in multiple words
On 5/31/09 5:36 PM, "Alec" wrote: > http://docs.jquery.com/Plugins/Autocomplete > > Say I have the following entry in a data array: > > "Quick brown fox" > > Is it possible to return this entry when I search for e.g. "qui fox"? > At this moment I can only get this result when searching for "qui" or > "fox", but not "qui fox". I guess what I'm looking for is a way to > split the input, and match each part against the data entries. if you're using local data, i don't know. probably not. if you're using a remote search, yes, program the search logic in your backend.
[jQuery] Re: AutoComplete with extraParam
On 5/30/09 5:15 PM, "Dushyant Patel" wrote: > > Hi All, > > I am using AutoComplete plug-in, its working great for me. But now i > have some new requirement and i am not able to make it work with > autocomplete. > > Requirement is as follow: > > Now i need 2 extra parameter to pass and these two parameter's value > would be depend on selected value of selected box. > > So let me explain in details: > > $(".mui_search_input").autocomplete('http://weburl/Service.svc/', { > minChars: 3, > matchContains: false, > autoFill: false, > scrollHeight:200, > cacheLength: 3, > mustMatch: true, > extraParams: { Parm1:"valueofselectionbox1", > Param2:"valueofselectionbox2"}, > > > Here valueofselectionbox1 and valueofselectionbox2 are selection box > next to search box. so i supposed to get values of those selection box > and pass as extra parameter. > > I tired with following but not working: > > extraParams: { Parm1:"$(.selectbox1).val()", Param2:"$(.selectbox2).val > ()"}, the extraparams need to be functions. otherwise you just set the params to whatever values are in those selects at the time you called $(".mui_search_input").autocomplete() see http://docs.jquery.com/Plugins/Autocomplete#Dependencies_between_fields
[jQuery] Re: Autocomplete Question
On 5/30/09 12:31 PM, "Marc" wrote: > I am using jquery.autocomplete in a search for schools. I have > optional fields (referenced as extraParams) which allow the user to > narrow the search to a specific state and city. > > This part works fine. If the user selects a state and city and then > initiates the search be entering a value into the autocomplete field, > then everything works well. > > My issue is that I need to execute the search and return results to > the autocomplete field when the user selects a state (and nothing has > been entered into the autocomplete field). > > Obviously, I have an onChange event in the State field which can > trigger the search event, but I don't know how to manually cause the > search to occur (passing a wildcard for the value of q). > > Any suggestions would be GREATLY appreciated. this question comes up periodically here. look in the archive for a thread called "Autocomplete plugin for multiple form fields from a JSON source". the kernel is to set minChars to 0 and then when you send two 'click' events to the field when you want the suggestions to pop open, e.g. inside your .result() event handler for state input, put: $("#city").setOptions({minChars: 0}).trigger('click').trigger('click'); or it could go in an onfocus handler on the city field, as you wish.
[jQuery] Re: Autocomplete two fields
On 5/30/09 5:15 AM, "Adrian Grigoras" wrote: > I use JQuery.Autocomplete to autocomplete values into one field. > Depending on the first field, I also need to populate a second field. > > For example: > > I autocomplete the Name field and depending on the selected name I > need to autocomplete also Phone field. > > It's possible to do that? it seems so. look at the Single Bird (remote) example here: http://jquery.bassistance.de/autocomplete/demo/ the backend returns an array with two members for each suggestion, the members being separated by the | character. autosuggest takes the first member for the field with autocomplete. a .result() handler takes the second member and puts it in the other field ('Hidden input'). this rather powerful trick of passing an array back for each suggestion seems to be undocumented. but you can see it by reading the demo source and observing the results from, say http://jquery.bassistance.de/autocomplete/demo/search.php?q=rob also look in function parse(data), line 371 of the plugin: row = row.split("|"); presumably you can use lots of array members on each row of results.
[jQuery] Re: Jquery Autocomplete Problem
i assume you are using this plugin? http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ if so, why did you put the call to autocomplete() inside an event handler? normally autocomplete() is called on page ready and it establishes its own event handlers. On 5/22/09 1:50 PM, "the_guru" wrote: > my script is-> > > $(".stock_item").live("keypress",function(){ > console.log($(this)); > $(this) > .autocomplete("includes/pages/stock_item_autocomplete.php",{ > width:150, > max:5, > multiple: true, > }).result(function(){ > > var name= $(this).val(); > > if(name.match("#")){ > var stock_id= parseInt( name.split("#")[0]); > > $(this).val(name.split("#")[1]); > > $(this).next("input[name=stock_item[]]").val(stock_id); > } > }); > > }); > > this script gets the 1#Nokia1166 and stores the 1 into the hidden > field but > my problem is it does not trigger even on the first time and some time > not at all > > help needed please
[jQuery] Re: Recommendations for jQuery method to play mp3 audio
On 5/20/09 10:02 AM, "SamCKayak" wrote: > Is there a cross-browser jQuery plug-in that can preload several > different mp3 audio files and provide play / stop methods? yes. http://plugins.jquery.com/search/node/mp3+type%3Aproject_project but for mp3 i really like 1bit. but it is not dependent on jquery so it may not meet your needs: http://1bit.markwheeler.net/
[jQuery] Re: [autocomplete] change ?q= to predefined param name or get field value for extraParams call
On 5/19/09 3:36 PM, "jakemonO" wrote: > > Is there a way to change the ?q= parameter name to something that was > predefined by the JSON emmitter? For example, Lotus Domino expects the > querystring to be of the form "?Startkey=... ". Alternately, I can put > that query in the extraParams call, without modifying the plugin, i think that's what you have to do. > but how do I populate the value > portion of extraParam? Is there a(n efficient) way for me to > accomplish what the autocompleter is accomplishing internally with its > lastWord($input.val()) call? i'm not sure what your question is but have you read: http://docs.jquery.com/Plugins/Autocomplete#Dependencies_between_fields
[jQuery] Re: [autocomplete] Can I validate and update the entered value before doing the search?
On 5/18/09 2:57 AM, "ulf.ren...@gmail.com" wrote: > My best though right now is to patch the plugin to include another > option - substituteValue - which could be a function that validates > and rewrites the data in any desired way before the match is done. i've thought in the past that a useful feature of the plugin would be an option to specify a general purpose search handler function. the plugin would call this handler when it has a search key that it wants suggestions for (either local or ajax search). it's a similar idea.
[jQuery] Re: [autocomplete] Can I validate and update the entered value before doing the search?
On 5/14/09 8:58 AM, "Ulf Renman" wrote: > When typing data into the autocomplete-field the list of matches is updated > at every key pressed. > Is it possible in any way to check and correct the data before doing the > match. Or could you alter the way the match is done. > > The perfect example is when you have lots of users entering decimal values > into a filed. Some people uses comma and some decimal-point. So you would > like to permit both "2.23" and 2,23" to be matched against 2.23 in the list. > > I have some other usecases aswell so I would really like some suggestions on > this. it allows you to format the suggestions from the backend but i'm not aware of the plugin having any feature for processing the field value before sending it to the backend. can't you do that processing in the backend itself?
[jQuery] Re: chained select box
On 5/14/09 3:20 AM, "phusys" wrote: > I need to show 3 select box (country, state, city) with data get from > a mysql database and when a user select a value from one of the select > box the other shows chained data. > How can I do this with jquery? fill the first select before delivering the form to the user. when the user selects from the first, use ajax to get data to use as options in the second. when the user selects from the second, use ajax to get data to use as options in the third. e.g. you could write the backend to format the data into html options and then .load() them into the form select element.
[jQuery] Re: JQuery and Ajax
On 5/13/09 2:23 PM, "nat" wrote: > I am working on adding asynchronous form submission inside a jquery > dialog. I am using .ajax(). > Everything is working correctly, but the submission takes longer than > I would like. > I am new to jquery and am unsure how to debug/optimize this. How do I > determine if the lag is in the front or backend? in safari, the web inspector will show you timings. and you could add code to your backend script to time its execution. then you can figure if the delays are frontend, network or backend. but i'd be surprised if it was frontend unless you're doing something odd in the client script.
[jQuery] Re: How to implement autocomplete with cross domain json with custom parameter
On 5/11/09 2:46 PM, "Dushyant Patel" wrote: > I tried and tired also, finding the way how can i implement > jQuery.Autocomplete plugin with cross domain json? > > Can any one help me? or provide me link for that instruction? not me. but this is worth reading: http://en.wikipedia.org/wiki/Same_origin_policy
[jQuery] Re: [autocomplete] Search Page Replacement
On 5/8/09 3:36 PM, "Logan Green" wrote: > This tab issue is driving me crazy. Has anyone found a hack/fix that > will allow the tab to work as expected...where the user hits tab once, > and moves to the next field? not that i am aware of. given the activity on this plugin (it's been nearly a year since 1.02) i'm pretty much resigned to coding my own. i think that will probably be easer than dealing with my own branch of the plugin, which is much more flexible (and therefore complex) than my requirements demand.
[jQuery] Re: [autocomplete] Bug in click function
On 5/5/09 1:59 PM, "tudela" wrote: > > Hi, I was using the autocomplete and found a bug in the click > function, follow the code: > > Actual code: > // In this code you need to click twice in the input element to show > the results. > .click(function() { > // show select when clicking in a focused field > if ( hasFocus++ > 1 && !select.visible() ) { > onChange(0, true); > } > > Fixed code: > // I just added ">=" instead of ">", so you only need one click to > show the results > .click(function() { > // show select when clicking in a focused field > if ( hasFocus++ >= 1 && !select.visible() ) { > onChange(0, true); > } > > That's it... there's an email thread in the archives of this list that shows that the two-clicks to show is intentional design. i have to admit i don't understand why it was designed this way. but when i made the same change that you explain above, it caused other UI problems with my app (sorry, i can't remember what) so i changed it back.
[jQuery] Re: [autocomplete] disable submit until valid selection is made
On 5/5/09 7:51 PM, "Seth" wrote: > I have a situation where the only valid inputs on my autocomplete > field are the ones supplied by my ajax method. Is there a way to > disable the submit button on my form until the input field contains > one of the autocomplete values? could you perhaps enable the submit button with result()? http://docs.jquery.com/Plugins/Autocomplete/result#handler
[jQuery] Re: [autocomplete] Invoking autocomplete dropdown on focus, before user types
On 5/5/09 6:09 PM, "Mike Harris" wrote: > Does anyone know how I can get the autocomplete dropdown list of > values to appear when the text field gains focus, before the user > types anything. I've been trying to do this, and have so far been > unsuccessful. Any help would be greatly appreciated. let me know if this works: $(selector).focus(function(){ $(this).setOptions({minChars: 0}).trigger('click').trigger('click'); } where selector selects your text field.
[jQuery] reading show/hide state
when using show() and hide(), what's the right way for the script to read the state of the element? i've found that attr('display') can be used but this seems like an undocumented hack and could fail in future releases of jquery.
[jQuery] Re: [autocomplete] Search Page Replacement
On 4/27/09 5:25 AM, "Matthew Vickery" wrote: > Thanks for your reply. I see what you mean about the tab key... I hope > someone offers you some advice so you can use the plugin without branching. i already have an auto-completion of my own that i wrote a few years ago before i knew of jquery. it requires only about 10% of the locs that autocomplete plugin uses because it only does what i need and not all that other stuff too. rewriting my code for the new app (maybe using jq) is perhaps less work than maintaining my own version of the plugin. i'm willing to take a bet on jq being around and supported in future. i'm not sure about autocomplete. > If you do find a solution I'd be glad to hear it too. Did you see my > response re; 'selectFirst: false' ? I don't know if this would help your > problem but it solved mine. it helps but it's not enough. for an example with "selectFirst: false": 1. go to http://jquery.bassistance.de/autocomplete/demo/ 2. click in the "Single Bird (remote):" text input. 3. type, say, "pal" and wait for the suggestions to appear. 4. hit tab. in my browser, the "Get Value" button focuses for a moment then the focus moves back to the "Single Bird (remote):" text input. it takes two tabs to get the focus out of there. that really runs against user expectations and makes no sense. for people used to working fast through forms with the keyboard only, this behavior will be inexplicable and annoying.
[jQuery] Re: [autocomplete] Search Page Replacement
On 4/26/09 9:31 PM, "Jordon Bedwell" wrote: >> this is one of two counter-intuitive keyboard behaviors i'm aware of. the >> other is tab, which most users would expect to get them to the next form >> element. > > I'm still scratching my head at how this is counter-intuitive? If you called > it that, you must not understand the entire scope of tab, and the fact that > it has no scope, it loops through the entire frame of the browser, including > the address bar and links. With JavaScript you can prevent it from looping > through links and the address bar by defining where it goes and what it > does. YES, if it did infact stay within forms if you select a form element > it would be counter-intuitive, but at this point, it is far from that based > on logic. There are also more reasons to redine the default behaviour of > tab. turning tab into a select, i..e making it work like enter, is counter- intuitive, to me. autocomplete does that. if you're in a form and the focus is on a text input and the form layout shows that the next form element is, say, another text element, you'd expect tab to get you to it. but with the autocomplete plugin, hit tab to move to the next input and what you typed gets over-written by a suggestion. that's not just unexpected, it's annoying.
[jQuery] Re: [autocomplete] Search Page Replacement
On 4/26/09 9:12 AM, "mattvick" wrote: > I need the list of results to appear without any of them highlighted > so hitting the return key submits the form without updating the text > in the search field. I still need the search field to update, and the > form submit, if any of the results in the list are highlighted and > clicked manually. this is one of two counter-intuitive keyboard behaviors i'm aware of. the other is tab, which most users would expect to get them to the next form element. > Will someone please point me in the right direction or even better > post an example so others can also benefit. i don't know for sure but i suspect that in most cases, changing the autocomplete keystroke behaviors requires changing the plugin code. which is a bit of a problem. i'd really like to use autocomplete in my app but without support (the author hasn't answered any email about autocomplete this month, afaict), seems like making it behave in a way that users won't complain about is going to mean branching.
[jQuery] Re: autocomplete
On 4/26/09 2:06 PM, "Marc" wrote: > > I have a silly question... > > I am using extraParams to pass additional field values via the URL > >$("#findHighSchool").autocomplete("autocomplete_ajax.cfm", { >width: 260, >selectFirst: false, >extraParams:{ STATE:function() { return $("#STATE").val > ();} >} >}); > > This works correctly. I need to pass a CITY field as well as STATE. > How do I configure the second extra parameter? All the syntax I've > tried fails to work. > > Do you use multiple extraParams lines or pass both params on the one > line? > > Any help greatly appreciated. it's hardly a silly question. see if this works: extraParams:{ STATE:function() { return $("#STATE").val(); }, CITY: function() { return $("#CITY").val(); } } something like that works in my app. it would be sweet if you could write something like: extraParams: function() { ... } and have your function return an object with lots of extra params. i looked at the plugin and it didn't seem easy enough for me to be willing to attempt.
[jQuery] Re: refactoring code
On 4/24/09 7:39 PM, "Calvin" wrote: > Does anyone have any advice in regard to refactoring jQuery code to > make it more efficient/elegant/simple? certain coding styles are implied by the jq apis, e.g. chaining, that i think may lead to efficiency gains. i've been reading other people's code to get ideas and learn. plugins are a place to look.
[jQuery] Re: Autocomplete Question
On 4/23/09 10:27 PM, "pjecty" wrote: > Is there's a way to link each seach result value in the localdata.js > to another page so that when i search for something and click it, it > goes to another page? could you write such redirection into a .result() handler? http://docs.jquery.com/Plugins/Autocomplete/result#handler
[jQuery] Re: Some pseudo help if you'd be so kind?
On 4/22/09 10:18 AM, "ldexterldesign" wrote: > > Hey guys, > > I have 10 separate posts displayed on a page. I want to hide 7 (of the > oldest) of them and display a link; 'show more posts' - kinda a > pagination thing I guess. > > My PHP pumps out 10 posts, and I'd like to do the hide/show with JS. > > I'm aware I could simply add and remove a height class, hiding/ > revealing the posts, but I'd like to make it a bit more complex and > have accurate control over how many posts are shown if my client turns > around and says he wants 5 posts displayed prior to the button being > clicked. > > Just thinking about how I might go about this in code I'm thinking of > doing it the following way. I'm not an excellent programmer, so the > time you'd, potentially, save me getting it clear in pseudo will most > likely save me a lot of time this evening. Hell, there might even be a > plug-in or simpler solution than below you can think of: > > - I get a unique 'post-x' ID for each of the posts, where 'x' is the > post ID, so I was thinking about just hiding the lowest 7 numeric post > IDs displayed on the page? > > Thoughts? say your posts all had class="foopost", could you do something like: $('.foopost').each(function() { if ( $(this).attr('id').match(/(\d+)$/)[1] > x ) { ... } });
[jQuery] Re: autocomplete
On 4/20/09 10:35 PM, "James" wrote: > Try: > > $("#isearch").autocomplete("search_result.php", { > extraParams:{isearch:$("#isearch").val()}, > width:542, > multiple: true, > matchContains:true, > cacheLength:0, > minChars:1, > delay:0 > }); i'm not sure that's going to help Pitt. your fragment will execute at page ready time and set the extra parameter "isearch" for subsequent searches to whatever the _initial_ value of the field happens to be, quite likely an empty string. if you want to send in an extra parameter an element's value at the moment the query is sent then you can use a function: $("#isearch").autocomplete("search_result.php", { extraParams:{isearch: function() { return $("#isearch").val(); }}, ... but in this case it will result in queries with both paraneters "q" and "isearch" set to the same value, which seems rather pointless.
[jQuery] Re: autocomplete
On 4/20/09 10:32 PM, "Pitt Phunsanit" wrote: > i found some blobem from autocomplete plugin > valible isearch don't send to php script the value of the field is sent in the "q" parameter. write your php script to use $_GET['q'] instead of $_GET['isearch']. > > $("#isearch").autocomplete("search_result.php?isearch="+$("#isearch").val(),{w > idth: > 542,multiple: true,matchContains:true,cacheLength:0,minChars:1,delay:0}); > and if put in event > $("#isearch").keyup(function(event){ > > $("#isearch").autocomplete("search_result.php?isearch="+$("#isearch").val(),{w > idth: > 542,multiple: true,matchContains:true,cacheLength:0,minChars:1,delay:0}); > }) > it have mulitple layer > how to fix it
[jQuery] Re: [autocomplete] Some Problems
On 4/19/09 10:17 PM, "HaiLin" wrote: > I have some problems about jQuery autoComplete plugin. I use this one: > http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/. > Here are problems: > (1) select in IE6. It seems this can be fixed by using bgiframe > plugin. Here is the author' optional: bgiframe plugin to fix select- > problems in IE, just include to apply to autocomplete. > But, it doesn't work properly. At first, it's ok. But scroll the > result list, and you will see select on top again. i can't verify this. could you provide sample markup? > (2) If you drag the scroll bar of result list, it will not close > result list when missing focus. i did verify this. i'd call it a bug. > (3) If I want to do more things when select one or clear result input > field, how to do that? i don't understand.
[jQuery] Re: Autocomplete problems with multiple fields
On 4/17/09 12:49 PM, "Lance A. Brown" wrote: > > Tom Worster wrote: >> >> what autocomplete plugin are you using? this one does not have a documented >> "parse" option: >> http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions > > Its the standard autocomplete plugin available at > http://docs.jquery.com/Plugins/Autocomplete > > I found the syntax for handling json data in it on another web page. standard warnings on using undocumented api features apply.
[jQuery] Re: Autocomplete problems with multiple fields
On 4/16/09 2:50 PM, "Lance A. Brown" wrote: > I'm working on adding autocomplete to a form which describes a > discussion paper. Each paper can have multiple authors and I want to > provide autocomplete on the author names. I'm new to jQuery so this > code is kind of rough. > > My java script is: > > // Begin > function parse_search(data) { > var result = []; > for (var i = 0; i < data.names.length; i++) { > result[i] = { data: data.names[i].name, > value: data.names[i].id, > result: data.names[i].name > }; > } > return result; > } > > function format_item(row, i, max) { > return row; > } > > function set_author_autocomplete() > { > var searchurl = $("#authsearch_url").attr("href"); > > $(".author_name").each(function (i) { >$(this).autocomplete(searchurl, { > dataType: 'json', > parse: parse_search, what autocomplete plugin are you using? this one does not have a documented "parse" option: http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions > formatItem: format_item > } > ) > } > ); > } > > > > $(document).ready(set_author_autocomplete); > //End two more points, though i don't know if they make any odds: it seems to be more conventional jq style (see http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery) to put all your jq script inside a block like this: $(document).ready(function() { }); and is there a reason to prefer: $(".author_name").each(function (i) { $(this).autocomplete(); }); over $(".author_name").autocomplete(); ?
[jQuery] Re: Validation plugin (bassistance.de) problem
i also detected some difference between the demo's behavior and the docs. i'm not sure what sequence of ui actions led to the result in the attached png but i've seen it twice now. On 4/17/09 8:17 AM, "Jörn Zaefferer" wrote: > > The behaviour is described here: > http://docs.jquery.com/Plugins/Validation/Reference#Validation_event > > Jörn > > On Fri, Apr 17, 2009 at 10:46 AM, Jonas wrote: >> >> Example form: http://jquery.bassistance.de/validate/demo/milk/ >> (this is the demo for the script on bassistance.de) >> >> When it does 'live' validation (on blur) it tells the user if the >> field is correct or incorrect. When you fill in the first field, tab >> to the next field, go back to the previous (allready filled in) field >> and clear it, it still counts as valid (notice the icon next to the >> field). >> >> Since the field is now empty, it should state as invalid, but it >> doesn't. >> >> This behaviour is random, sometimes it works, sometimes it doesn't. >> Sometimes it happens in the first field, sometimes on one of the >> other. >> >> It only happens before you try to submit the form, after a page >> submit everything works fine. >> >> Anybody who has a clue? >> <>
[jQuery] Re: [autocomplete] Submit form on click result
On 4/17/09 7:14 AM, "dajaniel" wrote: > My jquery is pretty sketchy so I was wondering if anybody knew how to > submit the form that the search field appears in on click of a result > (after having populated the textfield and any other fields)? Not sure > how to do this... check out the documentation for .result() in the autocomplete plugin, then look at the docs for jquery's .trigger(), here's the links: http://docs.jquery.com/Plugins/Autocomplete/result#handler http://docs.jquery.com/Events/trigger#eventdata
[jQuery] Re: Autocomplete plugin for multiple form fields from a JSON source [autocomplete]
On 4/16/09 6:44 PM, "tatlar" wrote: > So, I got around this by creating another JSON file that is just an > array of station names. Autocomplete now parses this just fine, and my > first field is completed. The next part was more tricky - how to > populate the second input field based on the number of report types (I > actually ended up using a element with the list > populated with the reports available. My solution is pretty inelegant, > but uses a nice option in Jorns plugin, the result() option (http:// > docs.jquery.com/Plugins/Autocomplete/result#handler). Using this, I > can get the match from the first autocomplete call, and write a > callback function that then goes via AJAX to my original complex JSON > object to just get the matching stations object. so in the end you used only a simple autocomplete and circumvented the issues of handling automatic pre-stuffing of multiple dependent autocomplete fields with your ajax-stuffed select element. if it works, it works. since this isn't the kind of solution i'm interested in, i only briefly read your code to see how you did it. you've avoided solving the problems i'm interested in. i have one comment on the code: you embedded an ajax query inside the .result() handler of an .autocomplete(). this works if users move in one direction through the form, which, in your case, is from autocompleting text field to the select. this is something i wanted to avoid; i need a non-hierarchical ui. the user has three text fields and can start typing in any of them and then move from there to either of the other two text fields, and when he or she does, the autocomplete list appears on focus constrained by the entries already selected.
[jQuery] Re: [Autocomplete] help: keyboard selection not working
On 4/15/09 4:21 PM, "Lance Speelmon" wrote: > Unfortunately, that did not work for me... I have tested with both > Safari4 and FF3. Any other ideas? Thanks, L try using only the style sheet supplied with the plugin. if keyboard nav works then you can work from that back to your preferred styling incrementally.
[jQuery] Re: Autocomplete plugin for multiple form fields from a JSON source [autocomplete]
i have an ajax backend onto a mysql table with about 25 million rows, including three searchable indexed text columns. i want a form with three text input fields, each with autocomplete. 1) if all fields are blank when the user starts to type into one of them then normal autocomplete happens on that field, independent of the others. 2) but if the user focuses on an empty field after an autocomplete selection has been made in one or both of the other fields then a list of all distinct values in that column of the big table, constrained by the selection(s) already made, is immediately displayed without any typing. each of the three fields has class 'auto' and there are three blocks like this one: $('#field1').autocomplete('suggest.php', { extraParams: { p: 'field1', field2: function() { return $('#field2').data('chosen') ? $('#field2').val() : ''; }, field3: function() { return $('#field3').data('chosen') ? $('#field3').val() : ''; } } }); so the back end can figure what's being looked for and what the constraints are, if any. to make a list of suggestions display on focus for 2) i have: var lastfocus = ''; $('.auto').setOptions({ minChars: 2 }).focus(function(){ if ( lastfocus != $(this).attr('id') && $(this).val() == '' && ( $('#field').data('chosen') || $('#field2').data('chosen') || $('#field3').data('chosen') ) ) $(this).data('chosen', false).setOptions( {minChars: 0}).trigger('click').trigger('click'); else $(this).setOptions({minChars: 2}); lastfocus = $(this).attr('id'); }).change(function(){ $(this).data('chosen', false); lastfocus = $(this).attr('id'); }).result(function(){ $(this).data('chosen', true); }); lastfocus is a hack: the focus event on a field triggers after a selection is made by clicking. i.e. with mouse selection focus moves to the list and then back to the text field. lastfocus deals with that. the 'chosen' data on each field indicates if the value in that field is one selected from the big table. two clicks are needed after setting minChars to 0 to display the list of suggestions. this is a quirk of the plugin. this is my first version of a script that seems to work in a way that wouldn't be too surprising to an unprepared user. i haven't given it much testing yet. comments and improvements would be welcomed. tom
[jQuery] Re: Autocomplete plugin for multiple form fields from a JSON source [autocomplete]
On 4/15/09 2:27 PM, "tatlar" wrote: > I am using Jorn's awesome autocomplete plugin in one form field to > allow a user to quickly narrow down which station they wish to view > visit times for. However, it would be really cool to extend this so > that when the selection is narrowed to one station, there is another > form input field listing all the available visit types that is > populated from the JSON file as well. is your question more to do with how to trigger and control the display of suggestions for the "another form input field" when a selection in the "one form field" is made? or is it more about using json formatted data? if the former, i've been working on that recently and could discuss what i've found.
[jQuery] Re: [autocomplete] charset
On 4/15/09 3:19 AM, "borutt" wrote: > GET /PHP/data.php?sid=0.179863580913668&q=%C4%8Duk %C4%8D is the urlencoding of the utf-8 codepoint for 'č'. > My input was "čuk" but like it's seen from GET params, q param has > strange chars. > But in QueryString it is ok. i don't know what 'QueryString'. if that's an input variable from the query in your back end script then all is well. > But when I check param q at the end of request (when it passes value > to sql) I get value "äťk". in which case, you have located the problem as being outside of anything to do with jquery. study your code between input and sql query and/or reconfigure your interpreter. > I have set all the header for character set to windows-1250. I think > that the problem is with ajax request in your script. it's not my script. > But I might be wrong. possibly so. i use jquery.autocomplete 1.0.2 in a utf-8 environment and it has no problem handling č or any other character i've tried including hebrew, greek, arabic, kana, cyrillic and others. windows-1250 is obsolescent. why not try using utf-8 instead? > Does this help you any more? i thought you were the one looking for help. maybe specify the charset of your javascript as windows-1250: http://www.capitolacomputing.com/intl_js_charset.htm
[jQuery] Re: assign event handler to multiple events
On 4/14/09 6:21 PM, "James" wrote: > > $('.things').bind('focus change click', function() { > // your code here > }); ah ha! thanks. that is tidy. tom
[jQuery] assign event handler to multiple events
i can assign a handler to one event type thus: $('.things').focus(function(){ $(this).data('foo', true); ... }); if i want to assign the same handler to several events, say focus, change, and click, what's the tidy way to write it [assuming my handler wants to access $(this)]?
[jQuery] Re: [autocomplete] charset
On 4/14/09 11:54 AM, "borutt" wrote: > >> was the page with the form containing the input element explicitly served >> with header "Content-Type: text/html; charset=Windows-1250"? (i check >> headers sent in WebKit Inspector, i'm sure there are other ways.) > > I have included in the html header this line: > that's not necessarily sufficient. if the the server sends, for example, charset=ISO-8859-1 in the headers then the user agent should ignore the meta HTTP-EQUIV. read this: http://www.w3.org/TR/1999/REC-html401-19991224/charset.html#h-5.2.2 >> have you set the accept-charset attribute in the form? > > I have not I never did. Will try this tomorrow. this has even lower priority than the meta HTTP-EQUIV. if the http header explicitly sets anything other than windows-1250 then that's what will take effect in the user agent. > A assumed that goes something wrong with value after it is submited by > ajax. > Because when I receive value from "q" argument it's already scrambled. > > Have any idea? make sure the header of the form page specifies windows-1250. check in your server logs to see exactly what the query string was in the ajax request. compare that with what you receive in the script. if the query string is correct but the input value in your script is wrong then it's probably to do with configuration of your script interpreter. if the query string received in the http server GET request is wrong then the user agent is probably using the wrong charset.
[jQuery] Re: [autocomplete] charset
On 4/14/09 4:36 AM, "borutt" wrote: > I'm having problem with charset on searching value, that is returned > in param "q". > On main page and od page from where script search for data I have > charset placed: > > main script: > was the page with the form containing the input element explicitly served with header "Content-Type: text/html; charset=Windows-1250"? (i check headers sent in WebKit Inspector, i'm sure there are other ways.) have you set the accept-charset attribute in the form? if using php on the back end: have you set php's default_charset config variable? are you using anything to encode the results sent from the search script, e.g. htmlspecialchars() -- don't! if using apache, have you checked that Windows-1250 is loaded as? > search script: > header( "Content-Type: text/html; charset=Windows-1250" ); jquery.autocomplete expects plain text back, so "Content-Type: text/plain; charset=Windows-1250" might work better. > I get some wierd characters when I use unicode characted like š,č,ž. those characters appear in Windows-1250 and ISO 8859-2 in addition to unicode.
[jQuery] Re: [Autocomplete] help: keyboard selection not working
i finally figured this out after a lot of trial and error. for keyboard navigation of the suggestions menus to work you must have a style rule for the element li.ac_over defined i your css. i was astonished when i discovered this but after reading the script i think i have a notion how this can be. anyway, there it is. put a rule for li.ac_over in your style sheet. On 4/6/09 6:52 PM, "Tom Worster" wrote: > > I'm unable to make the keyboard selection of suggestions from the > dropdown work in my project, otherwise it works fine and selection > with the mouse is possible. > > I'm using safari 3 and ff3. Keyboard selection in the demos is working > fine, so this seems not to be a browser issue. I've checked that I > have the newest jquery.autocomplete.js plugin code. I've checked > through the API docs and demo code and can't find anything that seems > to enable or disable keyboard selection. I'm stuck and would be > grateful for help. > > Here's the markup: > www.w3.org/TR/html4/loose.dtd"> > > > Test new suggest > > > > > > > > Artist >p> > > > > > > And the script: > $(document).ready(function() { > $('#artisttext').autocomplete('suggest-test.php', {extraParams: {p1: > 'as'} }); > $('.auto').setOptions({minChars: 2, delay: 200, max: 50}); > });
[jQuery] Re: [autocomplete] Regular Expression
On 4/7/09 6:26 PM, "Franck Y" wrote: > Is there anyway to implement a regular expression feature. > It does not need to be full regxp butat leat soemthing like star > > *ek will match Creek if what you're looking for is a substring match as opposed to a begins-with match then see the matchContains option: http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions and compare the first and third demos: http://view.jquery.com/trunk/plugins/autocomplete/demo/ if using remote search, your backend search code should implement whatever kind of search you need, which should be compatible with the caching options you set in autocomplete().
[jQuery] Re: [autocomplete] custom fields for remote URLs
On 4/7/09 1:00 PM, "skunkwerk" wrote: >i'm using the autocomplete plugin here (http://docs.jquery.com/ > Plugins/Autocomplete) and want to be able to use it with a remote URL, > while at the same time having access to have text displayed one way, > and selected another way (ie display a piece of text, but then change > what is entered into the input box once it's selected) > > with local data you can do this: > var data = [ {text:'Link A', url:'/page1'}, {text:'Link B', url: '/ > page2'} ]; > formatItem: function(item) { > return item.text; > } > > but how do I do this for a remote URL? the remote server is supposed > to return a bunch of matches separated by newline characters, but how > do I embed multiple fields in the results? if the value you to enter into the form's input element can be derived programmatically from the suggested text then you could make the modification using the formatResult option. there are examples of its use in the demo: http://view.jquery.com/trunk/plugins/autocomplete/demo/ if the value you want isn't derivable from the suggestions then the simples answer is probably to make it so. you could put both the suggestion text and the input value suitably marked up into each line of remote results. then use formatItem to hide the input value in the suggestion list and use formatResult to extract it.
[jQuery] [Autocomplete] One more question
There's a "focus grabbing" effect I'm interested in. I can demonstrate using the demo http://jquery.bassistance.de/autocomplete/demo/ : 1. I type "Ro" into Single Bird (remote), the suggestions appear. 2. But "Ro" is the value I want to enter into the field. So I want to move focus to another form field. The standard ways to do that are to click on the field I want to type in next or use (shift-)tab to get there. 3. If I click on the field I want to type in next. e.g. E-Mail (local), it gets the focus for a moment and then the focus moves back to Single Bird (remote). That's odd. Same problem with pressing tab or shift-tab. It seems a field grabs its focus back if I don't use any of its suggestions. I see the same in FF3 and Safari3. Is this focus grabbing the intended behavior of Autocomplete? tom
[jQuery] Re: [autocomplete] How to man ually trigger event for displaying results an d suggestions in Autocomplete by Jörn??
On 4/7/09 2:19 AM, "enriquepalaci...@gmail.com" wrote: > My cuestion is about this great autocomplete plugin by Jörn, i got it > working using ajax and all... But theres no way to display the results > manually??? i'm interested in this too. i have three form fields, each with autocompletion queries that depend the values in the other two fields. when the user chooses from the suggestions for one field, i'd like to automatically move focus to the next field and display its suggestions with q='' but constrained by the choice just made for the first field using extraParams. triggering some kind of event(s) for the 2nd field from the .result() handler of the first seems the way to go but i've made no progress. i read an old thread from this group yesterday that discussed something like this but i can't find it now.