marius-q2WWz6np9wsLdNzq/jA/7A@public.gmane.org
2008-Jun-10 12:51 UTC
Evaluate form request
Hi, I am having trouble with evaluation of submitted form. I do this: <input type="button" value="click me" onclick="javascript: $(''myform'').request({ method: ''post'', onComplete: submit_update });"> The form is submitted properly and submit_update function is called upon completion. The thing is that the returned html code contains javascripts which should be evaluated and I simply can''t force prototype to do this. I tried evalScripts: true but it doesn''t work. Any ideas? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
The evalScripts option is used by Ajax.Updater to evaluate the scripts in an Ajax request before updating an element. Ajax.Request (which is what form.request() boils down to) doesn''t do any evaluation or updating for you, you have to do it yourself. In the body of your handler, you will have to do something like the following: function submit_update(response) { response.responseText.evalScripts(); } Or, better, just to be safe if you have long-running scripts: function submit_update(response) { var body = response.responseText; body.evalScripts.bind(body).defer(); } -Fred On Tue, Jun 10, 2008 at 7:51 AM, marius-q2WWz6np9wsLdNzq/jA/7A@public.gmane.org < marius-q2WWz6np9wsLdNzq/jA/7A@public.gmane.org> wrote:> > Hi, > > I am having trouble with evaluation of submitted form. I do this: > > <input type="button" value="click me" onclick="javascript: > $(''myform'').request({ > method: ''post'', > onComplete: submit_update > });"> > > The form is submitted properly and submit_update function is called > upon completion. The thing is that the returned html code contains > javascripts which should be evaluated and I simply can''t force > prototype to do this. I tried evalScripts: true but it doesn''t work. > Any ideas? Thanks. > > >-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
marius-q2WWz6np9wsLdNzq/jA/7A@public.gmane.org
2008-Jun-10 14:39 UTC
Re: Evaluate form request
Thanks. This is exactly what I needed. On Jun 10, 2:28 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote:> The evalScripts option is used by Ajax.Updater to evaluate the scripts in an > Ajax request before updating an element. Ajax.Request (which is what > form.request() boils down to) doesn''t do any evaluation or updating for you, > you have to do it yourself. In the body of your handler, you will have to > do something like the following: > > function submit_update(response) { > response.responseText.evalScripts(); > > } > > Or, better, just to be safe if you have long-running scripts: > > function submit_update(response) { > var body = response.responseText; > body.evalScripts.bind(body).defer(); > > } > > -Fred > > On Tue, Jun 10, 2008 at 7:51 AM, mar...-q2WWz6np9wsLdNzq/jA/7A@public.gmane.org < > > > > mar...-q2WWz6np9wsLdNzq/jA/7A@public.gmane.org> wrote: > > > Hi, > > > I am having trouble with evaluation of submitted form. I do this: > > > <input type="button" value="click me" onclick="javascript: > > $(''myform'').request({ > > method: ''post'', > > onComplete: submit_update > > });"> > > > The form is submitted properly and submit_update function is called > > upon completion. The thing is that the returned html code contains > > javascripts which should be evaluated and I simply can''t force > > prototype to do this. I tried evalScripts: true but it doesn''t work. > > Any ideas? Thanks. > > -- > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---