Nice and clean. i like. Well, that settles it, no more core change requests for me; i'll be over at the general help group for future assists like this. :) -joe t.
On Feb 8, 4:28 pm, Mike Rumble <[email protected]> wrote: > if it's just a case of not wanting to use 'writeAttribute' on each > use, then I'd suggest using Function#wrap to provide a wrapper for > Form#request rather than modifying source adding. > > Came up with this in about five minutes... > > Element.addMethods('form', { > request : Form.Methods.request.wrap(function(proceed, element){ > var url = Object.isString(arguments[2]); > if(url) element.writeAttribute('action', arguments[2]); > return proceed(element, (url) ? arguments[3]||{} : arguments[2]|| > {}); > }) > > }); > > $('my-form').observe('submit', function(e){ > e.stop(); > this.request('/new/url', { > method : 'get' > }); > > }); > > Worth noting that this will still work in the 'old' way of not > specifying a URL. > > Hope this helps. > > Mike. > > On Feb 4, 10:08 pm, "joe t." <[email protected]> wrote: > > > i've had an ongoing need to make Form#request less dependent on the > > FORM's action attribute. i either need to keep calling > > $("formID").writeAttribute({action:...}).request(...) > > > or take the long way around with > > new Ajax.Request(url,{parameters:Form#serialize(), ...}); > > > What are the hazards of allowing the options Object to accept the url > > as well: > > > myCode.js: > > $("formID").request({url:"server_script.php", onSuccess:...}); > > > prototype.js 1.6.0.3 ~3558: > > var params = options.parameters, > > action = form.readAttribute('action') || options.url || ''; > > > Now, i see immediately that the url option would ultimately get passed > > upward into Ajax.Base.options, but does this cause any trouble? i'm > > just curious, because although it may not get much support, i'd like > > to try it out. > > > Or, if someone has a better suggestion, i'm open. i'm just sick of > > calling #writeAttribute all the time, and i want to avoid putting a > > fixed action value in the HTML. > > -- > > joe t. > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" 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/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---
