I'm running into something similar.  The result handler has no
corrollary for cases where you aren't using mustMatch, and want to
take some action if the user doesn't select something.  For example, I
want to put the ID from the extra data value into a hidden field when
it matches, but want to clear that hidden field if it doesn't match.

I don't see a foolproof way to do this right now via events from the
autocomplete.  So, instead I have a second JavaScript function that is
attached to the blur for the autocomplete field that goes and looks up
the value in the autocomplete field to see if it exists, and takes
that result and populates the hidden field (or clears it, if no
match).  But, this is clearly poor, given that it causes a second AJAX
request when none is actually needed.

So, is there a way to get an event in the case where result won't get
called?  Or, can someone point me at where I might hook into that in
the autocomplete code?  I'm not as experienced with JavaScript, so
haven't (on relatively quick glance) found the appropriate place to
hook in to add another hook/callback.

On Aug 20, 3:34 pm, Brad <[EMAIL PROTECTED]> wrote:
> I found a workaround, but it isn't great.
>
> If I attach a .blur(handler) to the autocomplete field I can clear the
> related fields when the user leaves that field by checking for
> val()==''.
>
> I'd love to hear that there is a way to do the same when mustMatch
> clears the autocomplete field. I'd like to clear the related fields
> immediately and not wait for the user to go to another field.
>
> On Aug 20, 2:45 pm, Brad <[EMAIL PROTECTED]> wrote:
>
> > Changing subject.
>
> >  I had originally entered "[AutoComplete] Detecting mustMatch failure"
> > and the forum ate "[AutoComplete]".
>
> > On Aug 20, 2:40 pm, Brad <[EMAIL PROTECTED]> wrote:
>
> > > I have a number of fields that are using the AutoComplete plugin
> > > instead of select menus. When a user enters and selects a match a
> > > number of other fields are populated via a .getJSON.
>
> > >         $("#f_orig_lookup")
> > >                 .autocomplete(
> > >                         "index.php",
> > >                         loc_lookup_obj) // loc_lookup_obj is a shared 
> > > configuration object.
> > >                 .result(function(event, data, formatted) {
> > >                         if (data){
> > >                                 $.getJSON(
> > >                                         
> > > "?type=remote&action=location_by_id&id="+data[1],
> > >                                         function(data){
> > >                                                 
> > > loadLocationInfo(data,'orig');
> > >                                         });
> > >                         } else {
> > >                                 // debug
> > >                                 alert ('no data'); // <- THIS NEVER ALERTS
> > >                         }
> > >                 });
>
> > > The problem I have is this. A user does a lookup, then returns to the
> > > same field and enters non-matching text. The mustMatch causes the
> > > autocomplete field to clear, but the autocomplete .result doesn't
> > > fire
>
> > > What I need to do is clear any pre-filled fields if mustMatch. Is
> > > there any easy way to detect that the mustMatch did it's job?

Reply via email to