Hey Onder,

Onder Arslan a écrit :
> because i want to use autocompleter, i want to usage like his :
> 
> if($('cbox').value == true)
>   new Ajax.Autocompleter("txt","hint","data.aspx",{minChars: 5});
> else
>   new Ajax.Autocompleter("txt","hint","other_data.aspx",{minChars: 5});
> 
> and cbox value change will dynamically when web site using.
> i want to use sometimes data.aspx or other_data.aspx for completion data

OK, but my system still works as long as you don't use keydown/blur 
events on $('txt') otherwise.  Imagine this:

   function defineAutocompleter(target_url) {
     var field = $('txt');
     if (field._ac) {
       $('txt').stopObserving('blur').stopObserving('keydown');
       delete field._ac;
     }
     field._ac = new Ajax.Autocompleter(field, 'hint', target_url,
       { minChars: 5 });
   } // defineAutocompleter

   new Field.EventObserver('cbox', function(cbox, checked) {
     defineAutocompleter(checked ? 'data.aspx' : 'other_data.aspx');
   });

This should cut it nicely.  Untested, but most likely to work.  Notice 
how using Field.EventObserver here spares you the need to react manually 
to your checkbox being checked/unchecked.

If you need more flexibility when calling defineAutocompleter (e.g. 
specify element/completionZone IDs or extra options, just add the 
arguments to it.

'HTH

-- 
Christophe Porteneuve aka TDD
[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to