Two links with one action

Hi,

How do I have two links that does the same action, save, and redirects
to different pages when different links are clicked. I am now using <%=
link_to_function ‘Previous’, “$(‘form_id’).submit()” -%>

Example:
When user click the ‘Previous’ link, he will be redirected to the
previous page. If the user click the ‘Next’ link, he will be redirected
to the next page.

Can someone please help me?

Thanks

Hi,
In link_to_function tag you can pass the id also depends upon the id
you can redirect the pages.

link_to_function("Previous", "$('form_id').submit()", :id => 

“previous”)
link_to_function(“Next”, “$(‘form_id’).submit()”, :id => “next”)

Regards

Abirami s

Abirami S. wrote:

Hi,
In link_to_function tag you can pass the id also depends upon the id
you can redirect the pages.

link_to_function("Previous", "$('form_id').submit()", :id => 

“previous”)
link_to_function(“Next”, “$(‘form_id’).submit()”, :id => “next”)

Regards

Abirami s

Hi,
I tried the link_to_function(“Previous”, “$(‘form_id’).submit()”, :id =>
“previous”)
link_to_function(“Next”, “$(‘form_id’).submit()”, :id => “next”)

and in the controller,

if params[:id] == “previous”
redirect_to :action => ‘previous_page’
elsif params[:id] == “next”
redirect_to :action => ‘next_page’
end

It gives me MISSING TEMPLATE error.Can someone tell me where did I go
wrong?

Thanks

Abirami S. wrote:

Hi,
do you have the rhtml page for previous_page and next_page

regards

Abirami

Hi,

Yes I do have previous_page.rhtml and next_page.rhtml. The MISSING
TEMPLATE error says that my save action’s template is missing not the
page that I want to redirect to is missing. I tried to use put to print
out the id and the result it prints out is nil. How do I let my
controller get the id from the link_to_function ?

Thanks

Hi,
do you have the rhtml page for previous_page and next_page

regards

Abirami

Hi,
Syntax for the link_to_function is

 link_to_function(name, *args, &block)

 like

 link_to_function("Previous",{:formId=>'form_id'},:id=>'previous')

 you can try this.... May be the params[:formId] have the value.

Regards

Abirami S

Abirami S. wrote:

Hi,
Syntax for the link_to_function is

 link_to_function(name, *args, &block)

 like

 link_to_function("Previous",{:formId=>'form_id'},:id=>'previous')

 you can try this.... May be the params[:formId] have the value.

Regards

Abirami S

Hi,

I tried the above code and it gives me an error saying, formIdform_id is
not defined. And it doesn’t submit anymore. Where did I do wrong?

Thanks

Hi,
can you explain clearly from start

Regards

Abirami S

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