How can i use link_to_remote with in form_for

Hi
anybody plz help me how can i use link_to_remote with in form_for… i
tried but no luck… if i use form_tag i can able to use link_to_remote
and made ajax call.but i need to use form_for …can anyone help me how
can i do with this.Thanks in advance.

On 14 Jul 2008, at 16:23, Palani K. wrote:

Hi
anybody plz help me how can i use link_to_remote with in
form_for… i
tried but no luck… if i use form_tag i can able to use
link_to_remote
and made ajax call.but i need to use form_for …can anyone help me
how
can i do with this.Thanks in advance.

A little detail would help (ie what doesn’t work if you just bung a
link_to_remote in your form ?)
Fred

why not use form_remote_for ?
gives you an ajax call to and the form_for stuff

anyway, please give us more details, what you want to
do, and/or what exactly your problem is.

for link_to_remote it doesn’t matter, if it’s within a form
or not and it’ll display & work as everywhere else.
so if you have problems, they’re specific to your code.

On 14 Jul 2008, at 17:12, Palani K. wrote:

=>‘Available’},:with => “‘user_name=’+$F(‘username’)”,:complete =>
‘alert(request.responseText)’

The problem here is that the id of your username textfield isn’t
username (it will be something like user_username). Check your html.

Fred

Palani K. wrote:

Hi
anybody plz help me how can i use link_to_remote with in form_for… i
tried but no luck… if i use form_tag i can able to use link_to_remote
and made ajax call.but i need to use form_for …can anyone help me how
can i do with this.Thanks in advance.

Hi
Actually i work user avilability check.ie) the newuser choose the
username and check whether his username already available or not.

my form looks:-

 <% form_for :user,@user, :url => {:controller => 'account', :action 

=> ‘signup_new’} do |f| %>

Choose Username : <%= f.text_field 'username', :class => "text-n", :tabindex => 2 %> <% link_to_remote "check",url => {:controller => 'account',:action =>'Available'},:with => "'user_name='+$F('username')",:complete => 'alert(request.responseText)'

In controller:

def Available
@u= User.find_by_username(params[:user_name])
if @u !=nil
if request.xhr?

      render(:text => "User Name Already exist" , :layout => false)
    else
     render(:text => "User Name doesn't exist ",:layout => false )

  end
end

end

 If i use form_tag it works fine (ie.Alert box popup with ajax 

response message)…If I use form_for_remote,form_remote_for the ajax
call doesn’t made this is my exact problem. I need use the form which
involves model also.

Frederick C. wrote:

On 14 Jul 2008, at 17:12, Palani K. wrote:

=>‘Available’},:with => “‘user_name=’+$F(‘username’)”,:complete =>
‘alert(request.responseText)’

The problem here is that the id of your username textfield isn’t
username (it will be something like user_username). Check your html.

Fred

Hi Fred
Thank you so much man…now its working for me… the is
error exactly what you specify. Thanks you so much

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs