Skip to content

Instantly share code, notes, and snippets.

@xylix
Created November 10, 2016 14:23
Show Gist options
  • Save xylix/5b4fc48d0f7afb735f7789bf9cda4398 to your computer and use it in GitHub Desktop.
Save xylix/5b4fc48d0f7afb735f7789bf9cda4398 to your computer and use it in GitHub Desktop.
Alpaca nested map test
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://code.cloudcms.com/alpaca/1.5.22/bootstrap/alpaca.min.css"/>
<link rel="stylesheet" href="index.css"/>
</html>
<body>
<div id="form"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.5/handlebars.min.js"></script>
<script src="https://code.cloudcms.com/alpaca/1.5.22/bootstrap/alpaca.min.js"></script>
<script src="index.js"></script>
</body>
$("#form").alpaca({
schemaSource: "./schema.json",
optionsSource: "./options.json",
postRender: control => {
control.on("change", function() {
console.log(this.getValue())
})
}
})
{
"fields": {
"outer": {
"type": "map",
"items": {
"inner": {
"type": "map"
}
}
}
}
}
{
"title": "Alpaca nested maps test",
"type": "object",
"properties": {
"outer": {
"title": "Outer map",
"type": "array",
"items": {
"type": "object",
"properties": {
"_key": {
"title": "Outer key",
"type": "string"
},
"inner": {
"title": "Inner map",
"type": "array",
"items": {
"type": "object",
"properties": {
"_key": {
"title": "Inner key",
"type": "string"
},
"value": {
"title": "Inner value",
"type": "string"
}
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment