Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow JX.Request to load resources in responses

Summary:
Currently, Javelin has no builtin support for loading CSS/JS before handling a response. Add some, since JX.Resource already exists and we're making forrays into this stuff in Phabricator.

This applies only to 'Javelin'-format responses.

Test Plan: See next diff: made Celerity emit resource URIs in ajax responses in Phabricator, verified resources were loaded before responses were processed.

Reviewers: vrana, chad, btrahan

Reviewed By: chad

CC: paulshen, tomo, aran

Maniphest Tasks: T2086

Differential Revision: https://secure.phabricator.com/D4003
  • Loading branch information...
commit d1586fc8ce044663f0e8e13aa124a2b41c243b57 1 parent db1a744
@epriestley epriestley authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/lib/Request.js
View
14 src/lib/Request.js
@@ -5,6 +5,7 @@
* javelin-behavior
* javelin-json
* javelin-dom
+ * javelin-resource
* @provides javelin-request
* @javelin
*/
@@ -355,8 +356,17 @@ JX.install('Request', {
JX.Stratcom.mergeData(
this._block,
response.javelin_metadata || {});
- this._done(response);
- JX.initBehaviors(response.javelin_behaviors || {});
+
+ var when_complete = JX.bind(this, function() {
+ this._done(response);
+ JX.initBehaviors(response.javelin_behaviors || {});
+ });
+
+ if (response.javelin_resources) {
+ JX.Resource.load(response.javelin_resources, when_complete);
+ } else {
+ when_complete();
+ }
}
} else {
this._cleanup();
Please sign in to comment.
Something went wrong with that request. Please try again.