Open noknokcody opened 2 years ago
I've recently become super interested in using the backbone javascript client for some React-based settings pages but I'm finding it increasingly difficult to use. I feel like the documentation needs a bit of an update.
Specifically speaking this link here
Some of the problems I've noticed are as follows
Documentation specifies the following for custom post types
// Extend wp.api.models.Post and wp.api.collections.Posts to load a custom post type const CustomPost = wp.api.models.Post.extend( { urlRoot: wpApiSettings.root + 'wp/v2/custom_post_slug', defaults: { type: 'custom_post_slug', }, } );
Yet when you extend the model and try save to the API it completely ignores the specified URL root.
In the section relating to custom post type collections it mentions an ambiguous type 'BLProduct'. Is this supposed to be CustomPost?
const CustomPosts = wp.api.collections.Posts.extend( { url: wpApiSettings.root + 'wp/v2/custom_post_slug', model: BLProduct, } ); const someCustomPosts = new CustomPosts(); someCustomPosts.fetch().then( ( posts ) => { // do something with the custom posts } );
Backbone client seems like an extremely powerful and handy tool and I feel it really needs some attention and love from wordpress.
I've recently become super interested in using the backbone javascript client for some React-based settings pages but I'm finding it increasingly difficult to use. I feel like the documentation needs a bit of an update.
Specifically speaking this link here
Some of the problems I've noticed are as follows
Extending custom post types won't take the new URL root
Documentation specifies the following for custom post types
Yet when you extend the model and try save to the API it completely ignores the specified URL root.
Documentation relating to custom post type collections specifies an ambiguous type.
In the section relating to custom post type collections it mentions an ambiguous type 'BLProduct'. Is this supposed to be CustomPost?
Some other minor issues I've discovered.
Backbone client seems like an extremely powerful and handy tool and I feel it really needs some attention and love from wordpress.