Note that there are some explanatory texts on larger screens.

plurals
  1. POActive Resource in Unobtrusive Javascript
    text
    copied!<p>I don't know any better way to ask this question than to give my situation.</p> <p>I have a reader application that needs to be made, on the page it will have the Table of Contents on the left side and the actual content of the book on right. The TOC content shows chapters and sections within the chapter. The content on the right will only shows one of those sections at a time, no preloading the whole book. When you click on the section in the TOC, makes an API call to a separate server that holds all the book data and returns the HTML to be displayed in the content section. </p> <p>I want to know if there is a way to make the application to use both unobtrusive javascript and active resource. Active resource would handle the interaction between the Rails Application and the server that holds the book content. The unobtrusive javascript would be the controller between the table of contents and the content on the right.</p> <p>I guess what I'm wondering most of all, beyond just its possibility, is if I can integrate this is such a way that I don't need to make unnecessary api calls. Currently, I can't figure out how this would work without it making an api call to rails then making another api call to the book content provider. </p> <p>Thanks for your help in advance!</p> <p>@tab</p> <p><strong>Edit:</strong></p> <p>The Content model would be used to talk to the external API using ActiveResource. UJS would be used to call that model and display that returned content on the page. So the flow would sort of be like, click link myapp.com/book.js. This would go to the controller book#index that would initialize a variable that gets its data from the content model. The content model would use ActiveResource to make an API call to the external content server and would return html. The html that would be returned would be filtered back out and displayed on the page.</p> <p>There will certainly be some caching, but the page itself will also need to be dynamic enough to allow editing of the content.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload