2011-03-20 80 views
0

所以我有這個按鈕:打開一個按鈕,一個鏈接以完全相同的功能

<%= button_to "+1", video_votes_path(:video_id => video.id, :type => "up"), :remote => true %> 

它調用video_votes控制器的創建方法,並且還設置PARAMS [:類型]。我想把這個按鈕變成一個鏈接,這樣做是完全一樣的。我該怎麼做呢?

+0

不想你的按鈕,你想作爲鏈接的css類做的伎倆,而不是ajax遠程?這就是我所做的:在用戶pov中,查看它是一個鏈接,但他單擊了一個提交表單的按鈕。 – 2011-03-20 11:59:04

回答

1
button_to "+1", video_votes_path(:video_id => video.id, :type => "up"), :remote => true 
=> 
link_to "+1", video_votes_path(video, :type => "up"), :remote => true, :method => :post 
0

更改button_tolink_to_remote帶有一個額外的參數::method => :post,並取出remote

呃,如果你想要一個GET,就省掉method

+1

爲什麼要拿出遙控器?它不應該是'link_to'並且通過'remote => true'作爲選項嗎? – 2011-03-20 07:06:59

+1

'link_to_remote'已被棄用,支持'link_to' with'remote => true' – Zabba 2011-03-20 07:14:00

相關問題