Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
691 views
in Technique[技术] by (71.8m points)

ruby on rails 3 - link_to syntax with rails3 (link_to_remote) and basic javascript not working in a rails3 app?

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

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

should actually produce an alert on click. very simple. does not work on my rails3 project! (also no error output!) any ideas?

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

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

even the rails3 api does not help me here: http://rails3api.s3.amazonaws.com/index.html

help!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I believe your problem here is that you've set the link up to show the alert when it is licked, as opposed to when it is clicked. ;)

As for link_to_remote, it has changed with the switch to unobtrusive javascript. You can read about it here: http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in-rails-3.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...