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:
'source'
or 'rendered'
— we should make constants for these) that get passed to the render URL (_render/
— see Text(1): Built-In Render URLs)Subclasses will then be able to re-render their content quite easily:
_onMyCheckboxChanged() {
this.reloadContentFromServer(
this.CONTENT_TYPE_RENDERED_TEXT,
{
sortKeys: this._$sortKeys.is(':checked'),
},
this._$renderedParent);
}
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:
TextBasedReviewableView.renderContent()
) for the supported source typethis.trigger('contentReloaded', type, options, $el)
)