-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added serialization example Updates to tests
- Loading branch information
Showing
9 changed files
with
310 additions
and
34 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"title": "The Griswold Family Movie Collection", | ||
"movies": [{ | ||
"title": "Tron", | ||
"year": "1982", | ||
"actors": [{ | ||
"name": "Jeff Bridges" | ||
}, { | ||
"name": "Bruce Boxleitner" | ||
}] | ||
}, { | ||
"title": "Breakin' 2: Electric Boogaloo", | ||
"year": "1984", | ||
"actors": [{ | ||
"name": "Lucinda Dickey" | ||
}, { | ||
"name": "Adolfo Quinones" | ||
}, { | ||
"name": "Michael Chambers" | ||
}], | ||
"reviews": [{ | ||
"author": "Ozone", | ||
"review": "Nothing's changed here. Story's still the same. People are still break dancing! Gotta love the 80's." | ||
}] | ||
}, { | ||
"title": "Groundhog Day", | ||
"year": "1993", | ||
"actors": [{ | ||
"name": "Bill Murray" | ||
}, { | ||
"name": "Andie MacDowell" | ||
}], | ||
"reviews": [{ | ||
"author": "Cassius Clay", | ||
"review": "This is an intriguing comedy about repeating the past." | ||
}, { | ||
"author": "Iron Mike", | ||
"review": "This is one of the best and most clever comedies I've ever seen!" | ||
}] | ||
}, { | ||
"title": "The Big Lebowski", | ||
"year": "1999", | ||
"actors": [{ | ||
"name": "Jeff Bridges" | ||
}, { | ||
"name": "John Goodman" | ||
}, { | ||
"name": "Steve Buscemi" | ||
}], | ||
"reviews": [{ | ||
"author": "Donnie", | ||
"review": "What movie was that again?" | ||
}, { | ||
"author": "Walter", | ||
"review": "Shut up Donnie." | ||
}] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"title": { | ||
"type": "string", | ||
"title": "Name of Movie Collection", | ||
"required": true | ||
}, | ||
"movies": { | ||
"type": "array", | ||
"title": "Movies", | ||
"items": { | ||
"$ref": "#/definitions/movie" | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"movie": { | ||
"type": "object", | ||
"properties": { | ||
"title": { | ||
"type": "string", | ||
"title": "Movie Name" | ||
}, | ||
"year": { | ||
"type": "string", | ||
"title": "Year" | ||
}, | ||
"actors": { | ||
"type": "array", | ||
"title": "Movie Actors", | ||
"items": { | ||
"$ref": "#/definitions/actor" | ||
} | ||
}, | ||
"reviews": { | ||
"type": "array", | ||
"title": "Movie Reviews", | ||
"items": { | ||
"$ref": "#/definitions/review" | ||
} | ||
} | ||
} | ||
}, | ||
"actor": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"title": "Name" | ||
} | ||
} | ||
}, | ||
"review": { | ||
"type": "object", | ||
"properties": { | ||
"author": { | ||
"type": "string", | ||
"title": "Author" | ||
}, | ||
"review": { | ||
"type": "string", | ||
"title": "Review" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> | ||
<title>Alpaca - HTML5 Forms for jQuery - References and Serialization</title> | ||
<meta name="keywords" | ||
content="jquery,bootstrap,forms,form,jquerymobile,jqueryui,mobile,json,json-schema,cloudcms,gitana,cms,content,uzquiano"/> | ||
<meta name="description" content="Customer Profile Form with Custom View Template."/> | ||
<meta name="author" content="Gitana Software Inc."/> | ||
<meta http-equiv="X-UA-Compatible" content="IE=9"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<link rel="icon" type="image/x-icon" href="../../../favicon.ico" /> | ||
|
||
<!-- jQuery --> | ||
<script type="text/javascript" src="../../../lib/jquery-latest.min.js"></script> | ||
<script type="text/javascript" src="../../../lib/jquery.tmpl.js"></script> | ||
|
||
<!-- Alpaca --> | ||
<script type="text/javascript" src="../../../components/alpaca/alpaca.js"></script> | ||
<link type="text/css" href="../../../components/alpaca/alpaca.css" rel="stylesheet"/> | ||
<link type="text/css" href="../../../components/alpaca/alpaca-jqueryui.css" rel="stylesheet"/> | ||
|
||
<!-- jQuery UI Support --> | ||
<script type="text/javascript" src="../../../lib/jquery-ui-latest/jquery-ui-latest.custom.min.js"></script> | ||
<link type="text/css" href="../../../lib/jquery-ui-latest/jquery-ui-latest.custom.css" rel="stylesheet"/> | ||
|
||
<!-- Additional CSS --> | ||
<link type="text/css" href="../../css/960.fluid.css" rel="stylesheet"/> | ||
|
||
<!-- Required for the Editor field (sample code viewing) --> | ||
<script src="../../../lib/ace/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script> | ||
|
||
<!-- Web Site --> | ||
<script type="text/javascript" src="../../lib/google-code-prettify/prettify.min.js"></script> | ||
<script type="text/javascript" src="../../js/themeswitchertool.js"></script> | ||
<script type="text/javascript" src="../../js/example.js"></script> | ||
<script type="text/javascript" src="../../js/footer.js"></script> | ||
<link type="text/css" href="../../css/site.css" rel="stylesheet"/> | ||
<link type="text/css" href="../../lib/google-code-prettify/prettify.css" rel="stylesheet"/> | ||
<script type="text/javascript" src="../../lib/tweet/jquery.tweet.js"></script> | ||
<link type="text/css" href="../../lib/tweet/jquery.tweet.css" rel="stylesheet"/> | ||
|
||
<script type="text/javascript" src="https://use.typekit.com/fnm3kpm.js"></script> | ||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script> | ||
|
||
</head> | ||
<body> | ||
<header> | ||
<div class='container_12'> | ||
<div class='actual-body'> | ||
<div class='grid_12'> | ||
<h1><img src="../../img/alpaca.png"><span>Easy Forms for jQuery</span></h1> | ||
<div class="resource-bar"> | ||
<a href="../../../index.html">Home</a> | ||
<a href="../../../web/download.html">Downloads</a> | ||
<a href="javascript:void(0);" class="current">Documentation</a> | ||
<a href="../../forms/customer-profile/edit-form.html">Forms</a> | ||
<a href="../../../web/tutorials.html">Tutorials</a> | ||
<a href="../../../web/consulting.html">Consulting</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</header> | ||
<div class='container_12'> | ||
<div class="actual-body"> | ||
<div class="grid_3"> | ||
<div class="container_12 side-bar"> | ||
</div> | ||
</div> | ||
|
||
<div class="grid_9"> | ||
<div class="container_12"> | ||
<div class="widget"> | ||
<div class="widget-body"> | ||
|
||
<div class='grid_12 alpaca-example-header' id='serialization' alpaca-types=''> | ||
|
||
<h1>Using References with Serialization</h1> | ||
<p> | ||
Serialization is the process of taking the data contained in a form and converting | ||
it to JSON. Alpaca serializes references for you automatically, taking into account | ||
nested structures and types. | ||
</p> | ||
|
||
<!-- Example #1: Serialized composite object (with references) --> | ||
<div class='grid_12 alpaca-example-case'> | ||
<h2>Example #1: Serialized composite object with references</h2> | ||
<p> | ||
This example provides a complex object with nested references. It is loaded with | ||
data. When you click the "serialize" button, the JSON is produced and displayed. | ||
</p> | ||
|
||
<button id="serialize">Serialize</button> | ||
<div id="field1"></div> | ||
|
||
<script type="text/javascript" id="field1-script"> | ||
$(function() { | ||
$("#field1").alpaca({ | ||
"schemaSource": "./serialization-schema.json", | ||
"dataSource": "./serialization-data.json", | ||
"postRender": function(form) { | ||
|
||
$("#serialize").click(function() { | ||
|
||
var json = form.getValue(); | ||
|
||
alert(JSON.stringify(json)); | ||
}); | ||
|
||
} | ||
}); | ||
}); | ||
</script> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
<!-- BEGIN DISCUSSIONS --> | ||
<div class="alpaca-discussions"></div> | ||
<!-- END DISCUSSIONS --> | ||
|
||
<div class="clear height-fix"></div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<footer> | ||
<div class="container_12"> | ||
<div class="grid_12 copyright"> | ||
Copyright © 2013 Gitana Software, Inc. | All Rights Reserved | ||
</div> | ||
</div> | ||
</footer> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.