Skip to content

Commit

Permalink
Reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
tonytlwu committed Mar 14, 2024
1 parent d04c344 commit 5fef42d
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions docs/API/core/widget.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,6 @@

## Core widget APIs

### Find widgets for a page

```js
Fliplet.Widget.find().then(function(instances) {
// Returns all widget instances for a page
});

Fliplet.Widget.find({ package: 'com.fiplet.image' }).then(function(instances) {
// Returns all image widget instances for a page
});

Fliplet.Widget.findOne({ package: 'com.fiplet.image' }).then(function(instance) {
// Returns the first image widget instance found on a page
});
```

### Get the JSON schema of a widget

You can use this method to fetch the JSON schema of a widget. The following widget packages are currently supporting this feature:

- `com.fliplet.form-builder`
- `com.fliplet.data-sources`

```js
Fliplet.Widget.getSchema("com.fliplet.form-builder").then(function (schema) {
// Use the schema
});
```

### Get the current widget instance id

<p class="info">This method is usually meant to be called from a widget interface, to get the widget instance id if necessary.</p>
Expand Down Expand Up @@ -65,6 +36,35 @@ Fliplet.API.request('v1/widget-instances/123').then(function (response) {
})
```

### Find widgets for a page

```js
Fliplet.Widget.find().then(function(instances) {
// Returns all widget instances for a page
});

Fliplet.Widget.find({ package: 'com.fiplet.image' }).then(function(instances) {
// Returns all image widget instances for a page
});

Fliplet.Widget.findOne({ package: 'com.fiplet.image' }).then(function(instance) {
// Returns the first image widget instance found on a page
});
```

### Get the JSON schema of a widget

You can use this method to fetch the JSON schema of a widget. The following widget packages are currently supporting this feature:

- `com.fliplet.form-builder`
- `com.fliplet.data-sources`

```js
Fliplet.Widget.getSchema("com.fliplet.form-builder").then(function (schema) {
// Use the schema
});
```

### Create a new widget instance

First, fetch widget IDs via [our API](https://api.fliplet.com/v1/widgets?fields=id,name,package). You can also fetch the `widgetId` for a specific package name, e.g. [see specific request](https://api.fliplet.com/v1/widgets?fields=id,name,package&package=com.fliplet.dynamic-lists) for the List from Data Source component.
Expand Down

0 comments on commit 5fef42d

Please sign in to comment.