Build on Fiddle
Page data
Let a prototype save votes, forms and cards, live, under rules Fiddle enforces. No backend to build.
A prototype can save records in named collections. Fiddle stores them with the artifact, checks every write against the rules you declare, and sends changes to everyone allowed to see them. Only prototypes have page data.
No-script helpers
Plain HTML attributes cover the common cases. Each saves one record per person.
<article data-fiddle-choice="layout" data-value="a">Option A</article>
<article data-fiddle-choice="layout" data-value="b">Option B</article>
<input data-fiddle-other="layout" placeholder="Something else?">
<textarea data-fiddle-field="concerns"></textarea>
<form data-fiddle-form="answers">…</form>- Choice: click to pick, click again to take it back. Add
data-fiddle-multipleto allow several. - Other: free text for answers the options miss.
- Field: inputs, textareas, selects and fieldsets, saved as people type.
- Form: named fields saved together on submit.
Answers are filled back in when the person returns.
From script
await fiddle.ready
const cards = fiddle.collection("cards")
await cards.add({ column: "well", text: "Shipped on time" })
cards.subscribe((records) => render(records))See Page data API for the whole surface.
Rules
Each collection has a rule for read, create, update and delete: viewers, editors, author or nobody. Undeclared collections are private to each person:
read: author create: viewers update: author delete: authorDeclare others in fiddle.json at the artifact's root, with an optional JSON Schema:
{
"collections": {
"cards": {
"read": "viewers",
"create": "viewers",
"update": "author",
"delete": "author",
"schema": {
"type": "object",
"required": ["column", "text"],
"properties": {
"column": { "enum": ["well", "improve", "actions"] },
"text": { "type": "string", "maxLength": 500 }
},
"additionalProperties": false
}
}
}
}Rules ship with each version, and a bad one fails the publish. Editors can always read and delete everything, to moderate.
See the results
Editors open ⋯ → Data for every collection, its records, who added them, and a CSV export. Agents use list_collections, list_records and write_record.
Editors-only content
data-fiddle-memberson any element removes it for viewers before the page is sent.- Files under
_private/are only served to editors.