Javascript form validation for In place editting in scriptac

Is there a way by which I can do form validation for form generated by
In
Place Editting of scritaculous?
The reason is, I want to avoid server roundtrip for checks which I can
perform at browser.

Regards,
Jatinder

Override the default method called by in_place_edit :

If you have <%= in_place_editor_field :object, :attribute %>

Define the following in your controller :

private
def set_object_attribute

  • find by id
  • update attribute
  • render :text => @object.attribute
    end

This will perform the validation, but won’t display the errors
however. You might want to play around with RJS to do so.

-Pratik

On 8/29/06, Jatinder S. [email protected] wrote:

Jatinder


rm -rf / 2>/dev/null - http://null.in

Dont judge those who try and fail, judge those who fail to try…

Found this.

http://rails.techno-weenie.net/question/2006/7/17/how-do-i-extend-the-rails-code-to-do-what-i-want

On 8/29/06, Pratik [email protected] wrote:

  • render :text => @object.attribute


rm -rf / 2>/dev/null - http://null.in

Dont judge those who try and fail, judge those who fail to try…


rm -rf / 2>/dev/null - http://null.in

Dont judge those who try and fail, judge those who fail to try…

Thanks for sharing the link Pratik.
The link explains how do I extend rails code to perform certain
validations
for in place editing control at server side; I am looking for performing
validations at client side.
for e.g.

Email:

On submission of above form, validate_form javascript method should be
called to perform javascript form validation, only then form should be
submitted.
I was wondering if scriptaculous IPE allows that? something like
onSubmitFormValidate as one of the options argument in IPE would have
been
great.

Regards,
Jatinder

I usually never perform client side validation. As it can be fooled
easily, and you might end up with a lot of junk code in your database.
So, even if you’re doing client side validation, server side
validation is a must.

Try looking into unobtrusive js plugin. That might be useful.

Thanks,
Pratik

On 8/29/06, Jatinder S. [email protected] wrote:

def set_object_attribute
On 8/29/06, Jatinder S. [email protected] wrote:

Regards,


rm -rf / 2>/dev/null - http://null.in

Dont judge those who try and fail, judge those who fail to try…

Yes I would definately add validations at server level too.
I will look through unobtrusive js plugin.

Thanks!

-Jatinder