# Replace link\_to\_remote bu button\_to\_function

**URL:** <https://www.ruby-forum.com/t/replace-link-to-remote-bu-button-to-function/121380>\
**Category:** Rails\
**Created:** [November 27, 2007, 1:44pm UTC](https://www.ruby-forum.com/t/replace-link-to-remote-bu-button-to-function/121380 "2007-11-27T13:44:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [November 27, 2007, 1:44pm UTC](https://www.ruby-forum.com/t/replace-link-to-remote-bu-button-to-function/121380/1 "2007-11-27T13:44:38Z")

</div>

Hi,

I am making use of a method button\_to\_function, and I want to use it in  
place of link\_to\_remot.

The issue I am facing is that I am not able to pass all the parameters  
of the remote function to button function.

I am sending both the code pieces…

\<%= link\_to\_remote(‘Go’,  
:condition=\>“btn\_disable(),checkNotSpecialCharacter() !=  
false” ,  
:url =\> { :action =\> ‘find’ } ,  
:with =\>"‘search=’+$(‘search’).value+’&single\_select=true’",  
:method =\> ‘get’,  
:update =\> ‘list\_table’) %\>

```
  <%= button_to_function 'Go',
                                 "openWin('#{url_for(
                                 :action => 'find',
         :method => 'get',
         :with

```

=\>"‘search=’+$(‘search’).value+’&structural\_unit=default’",  
:update =\> ‘list\_table’,  
:condition=\>“btn\_disable(),checkNotSpecialCharacter() !=  
false” )}’)",  
:class=\>‘n25x24’ %\>

The main problem being that The search functionality and the condition  
are not functioning .

Thank You

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [November 27, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/replace-link-to-remote-bu-button-to-function/121380/2 "2007-11-27T16:40:38Z")

</div>

I believe you want

submit\_to\_remote

Which works just like link\_to\_remote.

_submit\_to\_remote_(name, value, options = {})

Returns a button input tag that will submit form using XMLHttpRequest in  
the  
background instead of regular reloading POST arrangement. options  
argument  
is the same as in  
form\_remote\_tag[http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M000535](http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M000535).

On Nov 27, 2007 6:44 AM, Advait B.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [November 30, 2007, 9:27am UTC](https://www.ruby-forum.com/t/replace-link-to-remote-bu-button-to-function/121380/3 "2007-11-30T09:27:37Z")

</div>

Brian H. wrote:

> I believe you want
> 
> submit\_to\_remote
> 
> Which works just like link\_to\_remote.
> 
> _submit\_to\_remote_(name, value, options = {})
> 
> Returns a button input tag that will submit form using XMLHttpRequest in  
> the  
> background instead of regular reloading POST arrangement. options  
> argument  
> is the same as in  
> form\_remote\_tag[http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M000535](http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M000535).
> 
> On Nov 27, 2007 6:44 AM, Advait B.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Hi,

Thank you very much, the submit to remote function is working fine the  
way I want it to work, but the button which I am making use has a :class  
=\> ’ ’ which gives the button a distinct look, how could I include this.

\<%= submit\_to\_remote ‘GoBtn’,‘Go’,  
:url =\>{ :action =\> ‘find’},  
:with  
=\>“‘search=’+$(‘search’).value+‘&structural\_unit=default’”,  
:update =\> ‘list\_table’,  
:condition=\>“btn\_disable(),checkNotSpecialCharacter() !=  
false”,  
:method =\> ‘get’ %\>

I need to include the :class =\> ‘redbt80x80’, for the button to display  
a red color, how could I include this

Thank you

advait
