Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Status of Rails' link_to_function deprecation?

Tags:

What is the status of the link_to_function Javascript helper in Rails? I read, including in this stackoverflow question, that it was deprecated in Rails 3.0, then undeprecated, then deprecated again in 3.2.4. Is it something I can depend on and teach students? I just read the release notes (from a search) for Rails 3.2.8:

Reverted the deprecation of button_to_function and link_to_function helpers. Rafael Mendonça França

Where does this stand now?

like image 519
at. Avatar asked Jan 14 '13 19:01

at.


1 Answers

link_to_function is NOT deprecated in 3-2-stable branch and it won't be deprecated in 3-2-stable in future. But it IS depreacated in current master branch and will be deprecated in Rails 4.0 when it releases. So I guess it will removed from rails code in 4.1. So you can teach students to do this (from the rails 4 changelog):

We recommend the use of Unobtrusive JavaScript instead. For example:

link_to "Greeting", "#", class: "nav_link"  $(function() {   $('.nav_link').click(function() {     // Some complex code      return false;   }); }); 

or

link_to "Greeting", '#', onclick: "alert('Hello world!'); return false", class: "nav_link" 
like image 154
Vasiliy Ermolovich Avatar answered Oct 08 '22 16:10

Vasiliy Ermolovich