开发者

Nested resources, Ajax request

开发者 https://www.devze.com 2023-01-12 02:54 出处:网络
There are开发者_JAVA百科 two models: Exams and Resources. Every each exam could has many Resources

There are开发者_JAVA百科 two models: Exams and Resources.

Every each exam could has many Resources

Routes.rb

resources :exams do
    resources :resources
end

I want to get asynchronously all resources belongs to particular Exam. That should be realising in exam controller, yes?

But there's another problem, how should I send ajax request? I need to make it on_succes of another Ajax request (adding resource at the particular exam page). It is done by form_for with :remote, json returned by controller and js (jquery) file wich registers callbacks for ajax states.

Here are sources, An Ajax Branch.

Summary: I can add a resource to an exam (at /exams/:id) with Ajax but i want to reload Exam.resources when first Ajax is finished.

Please, Help me!


I did that.

Just returning json'ed @resource (which was just added) and inject it to page via jquery when ajax request is successed

0

精彩评论

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