[wp-trac] [WordPress Trac] #41549: REST API: Use `wp.apiRequest` helper in `wp.api` Backbone client

WordPress Trac noreply at wordpress.org
Sun Oct 1 14:03:22 UTC 2017


#41549: REST API: Use `wp.apiRequest` helper in `wp.api` Backbone client
-------------------------------------+-------------------------------------
 Reporter:  jnylen0                  |       Owner:  adamsilverstein
     Type:  enhancement              |      Status:  assigned
 Priority:  normal                   |   Milestone:  Future Release
Component:  REST API                 |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  needs-patch needs-unit-  |     Focuses:  javascript,
  tests dev-feedback                 |  administration, rest-api
-------------------------------------+-------------------------------------
Changes (by adamsilverstein):

 * keywords:  needs-patch needs-unit-tests => needs-patch needs-unit-tests
     dev-feedback
 * milestone:  4.9 => Future Release


Comment:

 @jnylen0 - [attachment:41549.diff] is a first pass at this.

 * Override `Backbone.ajax` with `wp.apiRequest.transport` - I looked at
 replacing first with `wp.apiRequest`, however I don't think we need the
 additional logic in `buildAjaxOptions` and this might break something.
 * Immediately restore Backbone.ajax after use
 * Adjust tests to override `wp.apiRequest.transport` for testing

 Not sure I like this - my concern here is that Backbone authors are used
 to the idea of being able to override `Backbone.ajax` to use an alternate
 method, for example [https://github.com/akre54/Backbone.NativeAjax this
 native implementation]. This would actually break that (for the client),
 requiring that they override `wp.apiRequest.transport` instead.

 Punting for now for further consideration.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41549#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list