Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backbone API docs seem incomplete and/or out of date #128

Open
noknokcody opened this issue Apr 19, 2022 · 0 comments
Open

Backbone API docs seem incomplete and/or out of date #128

noknokcody opened this issue Apr 19, 2022 · 0 comments

Comments

@noknokcody
Copy link

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

// 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.

image

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?

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
} );

Some other minor issues I've discovered.

  • No documentation on post.setMeta functions (they also seem to error out when doing so).
  • No documentation on how to use the MetaData models
  • Code does not appear to be open-sourced so debugging problems like these is really difficult

Backbone client seems like an extremely powerful and handy tool and I feel it really needs some attention and love from wordpress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant