-
Notifications
You must be signed in to change notification settings - Fork 262
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.
The connections
object in each box should allow you to programatically create/delete connections.
The candidates
object in each box can be used to control the search term and the current page.
Source code: https://github.com/scribu/wp-posts-to-posts/blob/master/admin/box.js
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()