Link_to syntax with rails3 (link_to_remote) and basic javascript not working in rails3 application?

I am wondering if the basic link_to syntax is completely broken in the current rails3 master server or if I am doing the wrong syntax here.

= link_to "name", nil, :onlick => "alert('Hello world!');"

should actually trigger a warning when pressed. very simple. not working on my rails3 project! (also no way out error!) any ideas?

for the general syntax of link_to, I could not find an example where I could combine link_to_remote with a confirmation, remote and html class (see my attempt below)

= link_to "delete", {:action => "destroy", :remote => true, :method => :delete, :confirm => "#{a.title} wirklich Löschen?" }, :class => "trash"

even rails3 api doesn't help me here: http://rails3api.s3.amazonaws.com/index.html

help!

+3
source share
6
+8
+13

nil :

= link_to "name", nil, :onclick => "alert('Hello world!');"
=> <a href="/currentpath", onclick="alert('Hello world!');">name</a>

:

= link_to "name", "#", :onclick => "alert('Hello world!');"
=> <a href="#", onclick="alert('Hello world!');">name</a>
+3

, , .

, csrf_meta_tag , Rails 3 . jQuery. :

<script type="text/javascript">
  jQuery.noConflict();
</script>

rails scripts , Prototype jQuery . , .

link_to, . link_to , , . button_to , , . , jQuery Prototype.

Rails 2.3.5, , , , Prototype : defaults .

:

http://webtech.union.rpi.edu/blog/2010/02/21/jquery-and-rails-3/

Prototype jQuery git Rails 3. , button_to show link_to. , , - .

+1

, : (

@robeastham: , , , .

" , ", ActiveRecord Mongoid ( ). , , , , : location response_with:

respond_with @themodel, :location => themodels_url

, :

button_to "Button Name", { :controller => "your/controller", :action => :action_name, :confirm => "Text for the pop-up"}, { :method => :<method name> }

.

button_to "Click Here", { :controller => "home", :action -> :set_completed, :confirm => "Mark the item complete?" }, { :method => :put }
+1

:

<%= link_to "Recommend", recommend_user_path(@user), :remote => true %>

, \layout\application.html.erb( ):

<%= csrf_meta_tags %>

, Rails v3.2.2 "", ""

0
source

Source: https://habr.com/ru/post/1737246/


All Articles