Skip to content

Javascript API

Cristi Burcă edited this page Apr 1, 2015 · 7 revisions

P2P uses the Backbone framework to organize its JavaScript code, so you should get familiar with it before going further.

The model classes and model collections are exposed via the window.P2PAdmin property. Views are not exposed.

Source code: https://github.com/scribu/wp-posts-to-posts/blob/master/admin/box.js

Examples

Manually trigger a refresh of the connection candidates for a given metabox:

P2PAdmin.boxes['YOUR_CONNECTION_TYPE'].candidates.sync()

Delete all the connections for a particular connection type (for the current post):

P2PAdmin.boxes['YOUR_CONNECTION_TYPE'].connections.clear()

Clone this wiki locally