Hi (I think Thomas?), I am trying to extending the AJAX autocompleter here, and would need to pass on additional params to the Framework I am using which is taking on the request. For this, I have changed the onObserverEvent function in controls.js as to the following: onObserverEvent: function() { this.changed = false; if(this.element.value.length>=this.options.min_chars) { this.startIndicator(); //here starts my change if(this.options.parameters && this.options.parameters.length>0){ this.options.parameters += ''&''; } else { this.options.parameters = ''''; } this.options.parameters += this.options.callback ? this.options.callback(this.element, Form.Element.getValue(this.element)) : Form.Element.serialize(this.element); //here ends my change new Ajax.Request(this.url, this.options); } else { this.active = false; this.hide(); } }, I would be very grateful if that change would make it over to the source base! regards, Martin
I think the change is not necessary, because you can just give the addtional params in the URL (use an URL like /xxx/xxx?yourparams...). The autocomplete data is sent in the POST DATA of the request, so this should work out fine. If you have objections, don''t hesitate to write back :) Thomas Am 10.07.2005 um 03:44 schrieb Martin Marinschek:> Hi (I think Thomas?), > > I am trying to extending the AJAX autocompleter here, and would need > to pass on additional params to the Framework I am using which is > taking on the request. > > For this, I have changed the onObserverEvent function in controls.js > as to the following: > > onObserverEvent: function() { > this.changed = false; > if(this.element.value.length>=this.options.min_chars) { > this.startIndicator(); > > //here starts my change > if(this.options.parameters && this.options.parameters.length>0){ > this.options.parameters += ''&''; > } else { > this.options.parameters = ''''; > } > > this.options.parameters += this.options.callback ? > this.options.callback(this.element, > Form.Element.getValue(this.element)) : > Form.Element.serialize(this.element); > > //here ends my change > > new Ajax.Request(this.url, this.options); > } else { > this.active = false; > this.hide(); > } > }, > > I would be very grateful if that change would make it over to the > source base! > > regards, > > Martin > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
right, this would be another solution. still, it''s not the same if parameters are sent in post or as get parameters. One problem might be the allowed length of these parameters, and here I might run into troubles: I am trying to send away the client side state of the web application, and doing that as a GET parameter could bring me into troubles, especially on IE. Additionally, I think that in the base Ajax class, the options variable was thought to be used for stuff like that, so I''d rather think the Autocompleter extension should also be able to handle this case ;) regards, Martin On 7/10/05, Thomas Fuchs <thomas@fesch.at> wrote:> I think the change is not necessary, because you can just give the > addtional params in the URL (use an URL like /xxx/xxx?yourparams...). > The autocomplete data is sent in the POST DATA of the request, so > this should work out fine. > > If you have objections, don''t hesitate to write back :) > > Thomas > > Am 10.07.2005 um 03:44 schrieb Martin Marinschek: > > > Hi (I think Thomas?), > > > > I am trying to extending the AJAX autocompleter here, and would need > > to pass on additional params to the Framework I am using which is > > taking on the request. > > > > For this, I have changed the onObserverEvent function in controls.js > > as to the following: > > > > onObserverEvent: function() { > > this.changed = false; > > if(this.element.value.length>=this.options.min_chars) { > > this.startIndicator(); > > > > //here starts my change > > if(this.options.parameters && this.options.parameters.length>0){ > > this.options.parameters += ''&''; > > } else { > > this.options.parameters = ''''; > > } > > > > this.options.parameters += this.options.callback ? > > this.options.callback(this.element, > > Form.Element.getValue(this.element)) : > > Form.Element.serialize(this.element); > > > > //here ends my change > > > > new Ajax.Request(this.url, this.options); > > } else { > > this.active = false; > > this.hide(); > > } > > }, > > > > I would be very grateful if that change would make it over to the > > source base! > > > > regards, > > > > Martin > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > >
Fair enough. :) Am 11.07.2005 um 01:23 schrieb Martin Marinschek:> right, this would be another solution. > > still, it''s not the same if parameters are sent in post or as get > parameters. One problem might be the allowed length of these > parameters, and here I might run into troubles: I am trying to send > away the client side state of the web application, and doing that as a > GET parameter could bring me into troubles, especially on IE. > > Additionally, I think that in the base Ajax class, the options > variable was thought to be used for stuff like that, so I''d rather > think the Autocompleter extension should also be able to handle this > case ;) > > regards, > > Martin > > On 7/10/05, Thomas Fuchs <thomas@fesch.at> wrote: > >> I think the change is not necessary, because you can just give the >> addtional params in the URL (use an URL like /xxx/xxx?yourparams...). >> The autocomplete data is sent in the POST DATA of the request, so >> this should work out fine. >> >> If you have objections, don''t hesitate to write back :) >> >> Thomas >> >> Am 10.07.2005 um 03:44 schrieb Martin Marinschek: >> >> >>> Hi (I think Thomas?), >>> >>> I am trying to extending the AJAX autocompleter here, and would need >>> to pass on additional params to the Framework I am using which is >>> taking on the request. >>> >>> For this, I have changed the onObserverEvent function in controls.js >>> as to the following: >>> >>> onObserverEvent: function() { >>> this.changed = false; >>> if(this.element.value.length>=this.options.min_chars) { >>> this.startIndicator(); >>> >>> //here starts my change >>> if(this.options.parameters && >>> this.options.parameters.length>0){ >>> this.options.parameters += ''&''; >>> } else { >>> this.options.parameters = ''''; >>> } >>> >>> this.options.parameters += this.options.callback ? >>> this.options.callback(this.element, >>> Form.Element.getValue(this.element)) : >>> Form.Element.serialize(this.element); >>> >>> //here ends my change >>> >>> new Ajax.Request(this.url, this.options); >>> } else { >>> this.active = false; >>> this.hide(); >>> } >>> }, >>> >>> I would be very grateful if that change would make it over to the >>> source base! >>> >>> regards, >>> >>> Martin >>> _______________________________________________ >>> Rails-spinoffs mailing list >>> Rails-spinoffs@lists.rubyonrails.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >>> >>> >> >> >
Forget whatever I said - it doesn''t work ;) the autocomplete prefix keeps getting added to the options string - the options string is never resetted, and so we end up with all autocomplete actions appended one after the other. I am instead trying to get this callback function thing up and running. regards, Martin On 7/11/05, Thomas Fuchs <thomas@fesch.at> wrote:> Fair enough. :) > > Am 11.07.2005 um 01:23 schrieb Martin Marinschek: > > > right, this would be another solution. > > > > still, it''s not the same if parameters are sent in post or as get > > parameters. One problem might be the allowed length of these > > parameters, and here I might run into troubles: I am trying to send > > away the client side state of the web application, and doing that as a > > GET parameter could bring me into troubles, especially on IE. > > > > Additionally, I think that in the base Ajax class, the options > > variable was thought to be used for stuff like that, so I''d rather > > think the Autocompleter extension should also be able to handle this > > case ;) > > > > regards, > > > > Martin > > > > On 7/10/05, Thomas Fuchs <thomas@fesch.at> wrote: > > > >> I think the change is not necessary, because you can just give the > >> addtional params in the URL (use an URL like /xxx/xxx?yourparams...). > >> The autocomplete data is sent in the POST DATA of the request, so > >> this should work out fine. > >> > >> If you have objections, don''t hesitate to write back :) > >> > >> Thomas > >> > >> Am 10.07.2005 um 03:44 schrieb Martin Marinschek: > >> > >> > >>> Hi (I think Thomas?), > >>> > >>> I am trying to extending the AJAX autocompleter here, and would need > >>> to pass on additional params to the Framework I am using which is > >>> taking on the request. > >>> > >>> For this, I have changed the onObserverEvent function in controls.js > >>> as to the following: > >>> > >>> onObserverEvent: function() { > >>> this.changed = false; > >>> if(this.element.value.length>=this.options.min_chars) { > >>> this.startIndicator(); > >>> > >>> //here starts my change > >>> if(this.options.parameters && > >>> this.options.parameters.length>0){ > >>> this.options.parameters += ''&''; > >>> } else { > >>> this.options.parameters = ''''; > >>> } > >>> > >>> this.options.parameters += this.options.callback ? > >>> this.options.callback(this.element, > >>> Form.Element.getValue(this.element)) : > >>> Form.Element.serialize(this.element); > >>> > >>> //here ends my change > >>> > >>> new Ajax.Request(this.url, this.options); > >>> } else { > >>> this.active = false; > >>> this.hide(); > >>> } > >>> }, > >>> > >>> I would be very grateful if that change would make it over to the > >>> source base! > >>> > >>> regards, > >>> > >>> Martin > >>> _______________________________________________ > >>> Rails-spinoffs mailing list > >>> Rails-spinoffs@lists.rubyonrails.org > >>> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > >>> > >>> > >> > >> > > > >
I''ll provide a fixed version anyway :) Thomas Am 11.07.2005 um 08:46 schrieb Martin Marinschek:> Forget whatever I said - it doesn''t work ;) > > the autocomplete prefix keeps getting added to the options string - > the options string is never resetted, and so we end up with all > autocomplete actions appended one after the other. > > I am instead trying to get this callback function thing up and > running. > > regards, > > Martin > > On 7/11/05, Thomas Fuchs <thomas@fesch.at> wrote: > >> Fair enough. :) >> >> Am 11.07.2005 um 01:23 schrieb Martin Marinschek: >> >> >>> right, this would be another solution. >>> >>> still, it''s not the same if parameters are sent in post or as get >>> parameters. One problem might be the allowed length of these >>> parameters, and here I might run into troubles: I am trying to send >>> away the client side state of the web application, and doing that >>> as a >>> GET parameter could bring me into troubles, especially on IE. >>> >>> Additionally, I think that in the base Ajax class, the options >>> variable was thought to be used for stuff like that, so I''d rather >>> think the Autocompleter extension should also be able to handle this >>> case ;) >>> >>> regards, >>> >>> Martin >>> >>> On 7/10/05, Thomas Fuchs <thomas@fesch.at> wrote: >>> >>> >>>> I think the change is not necessary, because you can just give the >>>> addtional params in the URL (use an URL like /xxx/xxx? >>>> yourparams...). >>>> The autocomplete data is sent in the POST DATA of the request, so >>>> this should work out fine. >>>> >>>> If you have objections, don''t hesitate to write back :) >>>> >>>> Thomas >>>> >>>> Am 10.07.2005 um 03:44 schrieb Martin Marinschek: >>>> >>>> >>>> >>>>> Hi (I think Thomas?), >>>>> >>>>> I am trying to extending the AJAX autocompleter here, and would >>>>> need >>>>> to pass on additional params to the Framework I am using which is >>>>> taking on the request. >>>>> >>>>> For this, I have changed the onObserverEvent function in >>>>> controls.js >>>>> as to the following: >>>>> >>>>> onObserverEvent: function() { >>>>> this.changed = false; >>>>> if(this.element.value.length>=this.options.min_chars) { >>>>> this.startIndicator(); >>>>> >>>>> //here starts my change >>>>> if(this.options.parameters && >>>>> this.options.parameters.length>0){ >>>>> this.options.parameters += ''&''; >>>>> } else { >>>>> this.options.parameters = ''''; >>>>> } >>>>> >>>>> this.options.parameters += this.options.callback ? >>>>> this.options.callback(this.element, >>>>> Form.Element.getValue(this.element)) : >>>>> Form.Element.serialize(this.element); >>>>> >>>>> //here ends my change >>>>> >>>>> new Ajax.Request(this.url, this.options); >>>>> } else { >>>>> this.active = false; >>>>> this.hide(); >>>>> } >>>>> }, >>>>> >>>>> I would be very grateful if that change would make it over to the >>>>> source base! >>>>> >>>>> regards, >>>>> >>>>> Martin >>>>> _______________________________________________ >>>>> Rails-spinoffs mailing list >>>>> Rails-spinoffs@lists.rubyonrails.org >>>>> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >>>>> >>>>> >>>>> >>>> >>>> >>>> >>> >>> >> >> >
And this works just fine! in the callback function, I am just adding my parameters to the option. By the way: great work with your script library, thank you! I have never seen such a clean javascript library... Thanks to your efforts even Apache MyFaces does not have to live without Ajax support anymore. Martin On 7/11/05, Martin Marinschek <martin.marinschek@gmail.com> wrote:> Forget whatever I said - it doesn''t work ;) > > the autocomplete prefix keeps getting added to the options string - > the options string is never resetted, and so we end up with all > autocomplete actions appended one after the other. > > I am instead trying to get this callback function thing up and running. > > regards, > > Martin > > On 7/11/05, Thomas Fuchs <thomas@fesch.at> wrote: > > Fair enough. :) > > > > Am 11.07.2005 um 01:23 schrieb Martin Marinschek: > > > > > right, this would be another solution. > > > > > > still, it''s not the same if parameters are sent in post or as get > > > parameters. One problem might be the allowed length of these > > > parameters, and here I might run into troubles: I am trying to send > > > away the client side state of the web application, and doing that as a > > > GET parameter could bring me into troubles, especially on IE. > > > > > > Additionally, I think that in the base Ajax class, the options > > > variable was thought to be used for stuff like that, so I''d rather > > > think the Autocompleter extension should also be able to handle this > > > case ;) > > > > > > regards, > > > > > > Martin > > > > > > On 7/10/05, Thomas Fuchs <thomas@fesch.at> wrote: > > > > > >> I think the change is not necessary, because you can just give the > > >> addtional params in the URL (use an URL like /xxx/xxx?yourparams...). > > >> The autocomplete data is sent in the POST DATA of the request, so > > >> this should work out fine. > > >> > > >> If you have objections, don''t hesitate to write back :) > > >> > > >> Thomas > > >> > > >> Am 10.07.2005 um 03:44 schrieb Martin Marinschek: > > >> > > >> > > >>> Hi (I think Thomas?), > > >>> > > >>> I am trying to extending the AJAX autocompleter here, and would need > > >>> to pass on additional params to the Framework I am using which is > > >>> taking on the request. > > >>> > > >>> For this, I have changed the onObserverEvent function in controls.js > > >>> as to the following: > > >>> > > >>> onObserverEvent: function() { > > >>> this.changed = false; > > >>> if(this.element.value.length>=this.options.min_chars) { > > >>> this.startIndicator(); > > >>> > > >>> //here starts my change > > >>> if(this.options.parameters && > > >>> this.options.parameters.length>0){ > > >>> this.options.parameters += ''&''; > > >>> } else { > > >>> this.options.parameters = ''''; > > >>> } > > >>> > > >>> this.options.parameters += this.options.callback ? > > >>> this.options.callback(this.element, > > >>> Form.Element.getValue(this.element)) : > > >>> Form.Element.serialize(this.element); > > >>> > > >>> //here ends my change > > >>> > > >>> new Ajax.Request(this.url, this.options); > > >>> } else { > > >>> this.active = false; > > >>> this.hide(); > > >>> } > > >>> }, > > >>> > > >>> I would be very grateful if that change would make it over to the > > >>> source base! > > >>> > > >>> regards, > > >>> > > >>> Martin > > >>> _______________________________________________ > > >>> Rails-spinoffs mailing list > > >>> Rails-spinoffs@lists.rubyonrails.org > > >>> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >>> > > >>> > > >> > > >> > > > > > > > >
So, just updated the autocompletion library in the SVN trunk, Ajax.Autocompleter now supports a parameters option. it works like this: On initializing, it saves the parameters option for later if it gets one: this.options.defaultParams = this.options.parameters || null; And on calling the Server, it does a: entry = encodeURIComponent(this.element.name) + ''='' + encodeURIComponent(this.getEntry()); this.options.parameters = this.options.callback ? this.options.callback(this.element, entry) : entry; if(this.options.defaultParams) this.options.parameters += ''&'' + this.options.defaultParams; now :) Thomas Am 11.07.2005 um 08:50 schrieb Martin Marinschek:> And this works just fine! > > in the callback function, I am just adding my parameters to the > option. > > By the way: great work with your script library, thank you! > > I have never seen such a clean javascript library... > > Thanks to your efforts even Apache MyFaces does not have to live > without Ajax support anymore. > > Martin > > > On 7/11/05, Martin Marinschek <martin.marinschek@gmail.com> wrote: > >> Forget whatever I said - it doesn''t work ;) >> >> the autocomplete prefix keeps getting added to the options string - >> the options string is never resetted, and so we end up with all >> autocomplete actions appended one after the other. >> >> I am instead trying to get this callback function thing up and >> running. >> >> regards, >> >> Martin >> >> On 7/11/05, Thomas Fuchs <thomas@fesch.at> wrote: >> >>> Fair enough. :) >>> >>> Am 11.07.2005 um 01:23 schrieb Martin Marinschek: >>> >>> >>>> right, this would be another solution. >>>> >>>> still, it''s not the same if parameters are sent in post or as get >>>> parameters. One problem might be the allowed length of these >>>> parameters, and here I might run into troubles: I am trying to send >>>> away the client side state of the web application, and doing >>>> that as a >>>> GET parameter could bring me into troubles, especially on IE. >>>> >>>> Additionally, I think that in the base Ajax class, the options >>>> variable was thought to be used for stuff like that, so I''d rather >>>> think the Autocompleter extension should also be able to handle >>>> this >>>> case ;) >>>> >>>> regards, >>>> >>>> Martin >>>> >>>> On 7/10/05, Thomas Fuchs <thomas@fesch.at> wrote: >>>> >>>> >>>>> I think the change is not necessary, because you can just give the >>>>> addtional params in the URL (use an URL like /xxx/xxx? >>>>> yourparams...). >>>>> The autocomplete data is sent in the POST DATA of the request, so >>>>> this should work out fine. >>>>> >>>>> If you have objections, don''t hesitate to write back :) >>>>> >>>>> Thomas >>>>> >>>>> Am 10.07.2005 um 03:44 schrieb Martin Marinschek: >>>>> >>>>> >>>>> >>>>>> Hi (I think Thomas?), >>>>>> >>>>>> I am trying to extending the AJAX autocompleter here, and >>>>>> would need >>>>>> to pass on additional params to the Framework I am using which is >>>>>> taking on the request. >>>>>> >>>>>> For this, I have changed the onObserverEvent function in >>>>>> controls.js >>>>>> as to the following: >>>>>> >>>>>> onObserverEvent: function() { >>>>>> this.changed = false; >>>>>> if(this.element.value.length>=this.options.min_chars) { >>>>>> this.startIndicator(); >>>>>> >>>>>> //here starts my change >>>>>> if(this.options.parameters && >>>>>> this.options.parameters.length>0){ >>>>>> this.options.parameters += ''&''; >>>>>> } else { >>>>>> this.options.parameters = ''''; >>>>>> } >>>>>> >>>>>> this.options.parameters += this.options.callback ? >>>>>> this.options.callback(this.element, >>>>>> Form.Element.getValue(this.element)) : >>>>>> Form.Element.serialize(this.element); >>>>>> >>>>>> //here ends my change >>>>>> >>>>>> new Ajax.Request(this.url, this.options); >>>>>> } else { >>>>>> this.active = false; >>>>>> this.hide(); >>>>>> } >>>>>> }, >>>>>> >>>>>> I would be very grateful if that change would make it over to the >>>>>> source base! >>>>>> >>>>>> regards, >>>>>> >>>>>> Martin >>>>>> _______________________________________________ >>>>>> Rails-spinoffs mailing list >>>>>> Rails-spinoffs@lists.rubyonrails.org >>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>> >>>> >>> >>> >>> >> >