Review UIs providing custom rendering options and backend rendering implementations would need to have a solid way of making these requests. Since re-rendering of content is going to be a common operation, we want to define it once, instead of in each specific review UI.

We have a JavaScript function for making API calls/HTTP requests called RB.apiCall. This takes care of normalizing data going into the request, putting up a spinner, and handling unexpected server errors. Our new method will wrap this to perform the call.

Let's call this new method reloadContentFromServer. It should take:

  1. A render source string type (let's say, 'source' or 'rendered' — we should make constants for these) that get passed to the render URL (_render/ — see Text(1): Built-In Render URLs)
  2. Options for the render (which the review UI may provide based on checkboxes or other widgets)
  3. The element that will be emptied out and then filled in with the new render content.

Subclasses will then be able to re-render their content quite easily:

_onMyCheckboxChanged() {
            sortKeys: this._$':checked'),

Now, we often attach things to the initial text content. For instance, a RB.TextCommentRowSelector. It'll be important to be able to re-attach. For this, we should probably:

  1. Attach the correct things we know we need (based on TextBasedReviewableView.renderContent()) for the supported source type
  2. Emit a signal when we've reloaded the content (this.trigger('contentReloaded', type, options, $el))