Link_to or helper to generate a javascript:history.back()?

Hello,

There is an link_to option or an helper that generate a link like :

Back

Thanks

you can use link_to “Back”, “javascript:histroy.back()”

oo00oo wrote:

Hello,

There is an link_to option or an helper that generate a link like :

Back

<%= link_to_function ‘Back’, ‘history.back()’ %>

Should do the trick…

Ok thanks, so no helper or option like :back => true
:slight_smile:

oo00oo wrote:

Ok thanks, so no helper or option like :back => true
:slight_smile:

Or you can add this to your ApplicationHelper.rb

def link_back
return link_to_function ‘Back’, ‘history.back()’
end

Then in your views:
<%= link_to_back %>

Guest wrote:

oo00oo wrote:

Ok thanks, so no helper or option like :back => true
:slight_smile:

Or you can add this to your ApplicationHelper.rb

def link_back
return link_to_function ‘Back’, ‘history.back()’
end

Then in your views:
<%= link_to_back %>

You can also use ‘redirect_to :back’ which will send you back to the
referring page… not quite the same thing.

_Kevin

Guest wrote:

oo00oo wrote:

Ok thanks, so no helper or option like :back => true
:slight_smile:

Or you can add this to your ApplicationHelper.rb

def link_back
return link_to_function ‘Back’, ‘history.back()’
end

Then in your views:
<%= link_to_back %>

you mean
<%= link_back %>

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