开发者

Problem using link_to with remote option in rails 3

开发者 https://www.devze.com 2023-03-18 15:08 出处:网络
I\'m working on rails 3 with link_to remote option. This is my code structure. View/punch/report开发者_开发百科.html.erb :

I'm working on rails 3 with link_to remote option.

This is my code structure.

View/punch/report开发者_开发百科.html.erb :


<%= link_to 'Punch report', punchreport_punch_index_path, :remote => true%>
<div id="punchform"> </div>

View/punch/punchreport.js.erb :


$("#punchform").html("<%= escape_javascript(render(:partial => "reportform"))%>");

and created a form inside

View/punch/_reportform.html.erb

and controller :

controller/punch_controller.rb


def report

end

def punchreport
  respond_to do |format|
   format.html { render report_punch_index_path }
   format.js 
  end
end

note : punchreport_punch_index_path : /punch/punchreport

    report_punch_index_path     : /punch/report

I don get the ajax request working. instead of that, it redirects the page.

Any help Thanks in advance


Sounds like your :remote => true is not being handled by an unobstrusive javascript event handler...

Do you have something called jquery-rails in your project? it should set a handler on "data-remote" attribute. Can you find it and post back what you have there?

0

精彩评论

暂无评论...
验证码 换一张
取 消