2012-07-16 5 views
2

레일즈 3.2.3 어플리케이션에서 Ajax와 jQuery를 사용하고 있습니다. 페이지에 링크가 있으며 단추로 바꾸고 싶습니다. 아래의 코드는 완벽한레일즈 - link_to and button_to

<%= link_to "More", {:controller => "home", :action => "test_method", :page=>@current_page }, :remote => true,:id => 'lnk_more' %> 

을하고있다하지만이 하나가 링크와 버튼

<%= button_to "More", {:controller => "home", :action => "test_method", :page=>@current_page }, :remote => true,:id => 'lnk_more' %> 

결과 HTML을하지 않는 것은 내가 잘못했을 여기에서

#link 
<a href="/home/test_method?page=1" data-remote="true" id="lnk_more" disabled="disabled">More </a> 


#button 
<form action="/home/test_method?page=1" class="button_to" data-remote="true" method="post"><div><input id="lnk_more" type="submit" value="More "><input name="authenticity_token" type="hidden" value="hFCuBR+88FYKEvNTZok+QRhxf6fHA+ucC6i2yc9hBEk="></div></form> 

입니다 ?

답변

3
<%= button_to "More", 
    { :controller => :home, :action=> :test_method, :page => @current_page}, 
    { :remote => true, :id => 'lnk_more' } 
%> 

기본적으로이 post로 설정되어 있기 때문에 당신은 방법 :method=>:get을 변경해야합니다 입력

<input id="lnk_more" type="submit" value="More"> 
+0

작동하지 않습니다. '@ current_page'는 어디에 있습니까? – Alexandre

+0

매개 변수'id'는 어디에 있습니까? – Alexandre

+0

@AlexMaslakov,이 컨텍스트의 매개 변수는 페이지입니다. –

1

에 ID를 제공집니다. 그리고 당신의 노선들은 아마 어떻게 그것이 작동 할 수 있도록 코드를 변경합니까 제대로

<%= button_to "More", {:controller => "home", :action => "test_method", :page=>@current_page }, :method=>:get, :remote => true,:id => 'lnk_more' %>

관련 문제