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.

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.

Palani Kumar 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| %> <tr> <td align=right><label for="choose_username">Choose Username : </label></td> <td align=left ><%= f.text_field 'username', :class => "text-n", :tabindex => 2 %></td> <td> <% link_to_remote "check",url => {:controller => 'account',:action =>'Available'},:with => "'user_name='+$F('username')",:complete => 'alert(request.responseText)'</td> </tr>

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.

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

Frederick Cheung wrote: