aartnicolai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Apr-17 19:20 UTC
scriptaculous InPlaceEditor validation
Hi, How can I validate the scriptaculous InPlaceEditor text field before sending it to the server. I would like to do an e-mail address validation. Cheers, Aart --~--~---------~--~----~------------~-------~--~----~ 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 InPlaceEditor is not really intended to behave like that. You can either cancel the edit, in which case the Ajax will not occur, or you can submit the changes in which case there is nothing you can do to stop the Ajax from being sent (aside from overriding the handleFormSubmission method). Why not just perform the validation on the server, where you have more control? -justin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the quick reply. I validate on the server as well, but the generated error message appears in the InPlaceEditir field. I just would like to see an javasscript alert.. On 17/04/2008, Justin Perkins <justinperkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > The InPlaceEditor is not really intended to behave like that. > > You can either cancel the edit, in which case the Ajax will not occur, > or you can submit the changes in which case there is nothing you can > do to stop the Ajax from being sent (aside from overriding the > handleFormSubmission method). > > Why not just perform the validation on the server, where you have more > control? > > -justin > > > >-- Groet, Aart --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Well you can turn off htmlResponse in your InPlaceEditor, then return javascript to be executed, such as doing an alert like you desire or, for a better user experience, displaying an error message next to the edit field. new Ajax.InPlaceEditor(''your field_id'', ''/some/url'', { htmlResponse:false }) Of course this means the you have to update the element upon success yourself instead of IPE doing it for you... $(''your_field_id'').update(''the new value'') -justin On Thu, Apr 17, 2008 at 2:53 PM, Aart Nicolai <aartnicolai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for the quick reply. > I validate on the server as well, but the generated error message appears in > the InPlaceEditir field. I just would like to see an javasscript alert.. > > > > On 17/04/2008, Justin Perkins <justinperkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > The InPlaceEditor is not really intended to behave like that. > > > > You can either cancel the edit, in which case the Ajax will not occur, > > or you can submit the changes in which case there is nothing you can > > do to stop the Ajax from being sent (aside from overriding the > > handleFormSubmission method). > > > > Why not just perform the validation on the server, where you have more > control? > > > > -justin > > > > > > > > > > -- > Groet, > > > > Aart > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Just in time.. This works better.. As interim solution a made a list hidden text fields to validate later on, but this works better.. Thanks! On 17/04/2008, Justin Perkins <justinperkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Well you can turn off htmlResponse in your InPlaceEditor, then return > javascript to be executed, such as doing an alert like you desire or, > for a better user experience, displaying an error message next to the > edit field. > > new Ajax.InPlaceEditor(''your field_id'', ''/some/url'', { htmlResponse:false > }) > > Of course this means the you have to update the element upon success > yourself instead of IPE doing it for you... > > $(''your_field_id'').update(''the new value'') > > -justin > > > On Thu, Apr 17, 2008 at 2:53 PM, Aart Nicolai <aartnicolai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Thanks for the quick reply. > > I validate on the server as well, but the generated error message > appears in > > the InPlaceEditir field. I just would like to see an javasscript alert.. > > > > > > > > On 17/04/2008, Justin Perkins <justinperkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > The InPlaceEditor is not really intended to behave like that. > > > > > > You can either cancel the edit, in which case the Ajax will not occur, > > > or you can submit the changes in which case there is nothing you can > > > do to stop the Ajax from being sent (aside from overriding the > > > handleFormSubmission method). > > > > > > Why not just perform the validation on the server, where you have more > > control? > > > > > > -justin > > > > > > > > > > > > > > > > > -- > > > Groet, > > > > > > > > Aart > > > > > > > > > >-- Groet, Aart --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It seems like "htmlResponse" is undocumented.. are there more? On 17/04/2008, Aart Nicolai <aartnicolai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Just in time.. This works better.. > As interim solution a made a list hidden text fields to validate later on, > but this works better.. > > Thanks! > > On 17/04/2008, Justin Perkins <justinperkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Well you can turn off htmlResponse in your InPlaceEditor, then return > > javascript to be executed, such as doing an alert like you desire or, > > for a better user experience, displaying an error message next to the > > edit field. > > > > new Ajax.InPlaceEditor(''your field_id'', ''/some/url'', { > > htmlResponse:false }) > > > > Of course this means the you have to update the element upon success > > yourself instead of IPE doing it for you... > > > > $(''your_field_id'').update(''the new value'') > > > > -justin > > > > > > On Thu, Apr 17, 2008 at 2:53 PM, Aart Nicolai <aartnicolai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > Thanks for the quick reply. > > > I validate on the server as well, but the generated error message > > appears in > > > the InPlaceEditir field. I just would like to see an javasscript > > alert.. > > > > > > > > > > > > On 17/04/2008, Justin Perkins <justinperkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > The InPlaceEditor is not really intended to behave like that. > > > > > > > > You can either cancel the edit, in which case the Ajax will not > > occur, > > > > or you can submit the changes in which case there is nothing you > > can > > > > do to stop the Ajax from being sent (aside from overriding the > > > > handleFormSubmission method). > > > > > > > > Why not just perform the validation on the server, where you have > > more > > > control? > > > > > > > > -justin > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > Groet, > > > > > > > > > > > > Aart > > > > > > > > > > > > > > > > > > > > -- > Groet, > > Aart-- Groet, Aart --~--~---------~--~----~------------~-------~--~----~ 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 documentation is lacking at the moment, due to being moved around. I''ve found it''s best to just read the source code, but I think a new documentation site is in the works. -justin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sorry Justin but "The InPlaceEditor is not really intended to behave like that. " is a not very realistic response. I think the validation is a so normal need and it will be mandatory in a serious project, don''t you think so? The other ways is a patch temporary solution, if not I can''t consider IPE a serious project Sorry On Apr 17, 10:35 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The documentation is lacking at the moment, due to being moved around. > I''ve found it''s best to just read the source code, but I think a new > documentation site is in the works. > > -justin--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Fri, Apr 18, 2008 at 8:40 AM, Garito <garito-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Sorry Justin but > "The InPlaceEditor is not really intended to behave like that. " is a > not very realistic response. I think the validation is a so normalValidation on the server is normal, but imo validation on the client should not be relied upon. It is up to you to decide if yo want to do it, but it will require overriding the default behavior in IPE. If you look at the source code for the IPE, you can see that it was never intended to perform client-side validation. Since it''s an Ajax form submission, what is the advantage of client-side validation? -justin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Fri, Apr 18, 2008 at 11:42 AM, Justin Perkins <justinperkins-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Fri, Apr 18, 2008 at 8:40 AM, Garito <garito-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Sorry Justin but > > "The InPlaceEditor is not really intended to behave like that. " is a > > not very realistic response. I think the validation is a so normal > > Validation on the server is normal, but imo validation on the client > should not be relied upon. It is up to you to decide if yo want to do > it, but it will require overriding the default behavior in IPE. > > If you look at the source code for the IPE, you can see that it was > never intended to perform client-side validation. > > Since it''s an Ajax form submission, what is the advantage of > client-side validation? > > -justin >Agreed, Client side validation is a time saver for the user -- not the server, and should never be relied upon, especially if the user knows how to use prototype and has firebug installed on firefox - haven''t you ever gone in and looked at how easy it is to mess with your own site using your knowledge of Prototype and firebug? or the web developer toolbar? put in all of your fancy schmancy editors and then turn off javascript support - does your site still work properly? at all? --~--~---------~--~----~------------~-------~--~----~ 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 advantage is pretty clear: you save a server connection only to know that the field is mandatory or a date-only data The server side validation is needed too but why not to save time, connections and server load with a very low effort? On 18 abr, 17:42, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Apr 18, 2008 at 8:40 AM, Garito <gar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Sorry Justin but > > "The InPlaceEditor is not really intended to behave like that. " is a > > not very realistic response. I think the validation is a so normal > > Validation on the server is normal, but imo validation on the client > should not be relied upon. It is up to you to decide if yo want to do > it, but it will require overriding the default behavior in IPE. > > If you look at the source code for the IPE, you can see that it was > never intended to perform client-side validation. > > Since it''s an Ajax form submission, what is the advantage of > client-side validation? > > -justin--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
That''s right. Server side validation is always required, using client side validation you can save a roundtrip to the server. From my point of view client side validation should be an option for IPE. On 19/04/2008, Garito <garito-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > The advantage is pretty clear: you save a server connection only to > know that the field is mandatory or a date-only data > The server side validation is needed too but why not to save time, > connections and server load with a very low effort? > > On 18 abr, 17:42, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Fri, Apr 18, 2008 at 8:40 AM, Garito <gar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Sorry Justin but > > > "The InPlaceEditor is not really intended to behave like that. " is a > > > not very realistic response. I think the validation is a so normal > > > > Validation on the server is normal, but imo validation on the client > > should not be relied upon. It is up to you to decide if yo want to do > > it, but it will require overriding the default behavior in IPE. > > > > If you look at the source code for the IPE, you can see that it was > > never intended to perform client-side validation. > > > > Since it''s an Ajax form submission, what is the advantage of > > client-side validation? > > > > -justin > > >-- Groet, Aart --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Sat, Apr 19, 2008 at 9:31 AM, Aart Nicolai <aartnicolai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> That''s right. Server side validation is always required, using client side > validation you can save a roundtrip to the server. From my point of view > client side validation should be an option for IPE.I recommend extending IPE to do what you want it to do, and if you are pleased with the enhancement, submit it as a patch. -justin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---