문제

So I'm trying to create a dashboard where once authenticated only a main page is initially rendered from rails, then any user interaction after that (like clicking on a nav tab or running a report etc.) will happen on the current page without redirecting to a new page.

I understand that this is most likely done by making AJAX calls to the server, but I feel like its not 'the rails way' to do this since it would include a lot of custom JS to be written. Is there a more 'rails way' I could be doing this, like with partials or some third party framework?

If this is a novice question thats because I am a novice developer. I couldn't find a straight answer to this elsewhere.

도움이 되었습니까?

해결책

Rails is a server side framework. What you are talking about seems to fall into the family of single page app. For that, custom js will definitely be needed. Rails does not have any major powers on client.

That said, I recommend you take a look into angularjs. It will cut-down your javascript code length by orders of magnitude and is a much better approach to client side javascript. It's readily testable too.

Even if you do choose to stay with jquery, prototype or some other traditional library, you can separate chunks of reusable code regarding ajax and all into various modules and reference them all over. It will reduce mess and help extensibility in long run. (But do take a look at angularjs if not already done so).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top