Current File : /home/obaba/public_html/admin/assets/plugins/dynatree/doc/sample-form.html |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Dynatree - Example</title>
<script src="../jquery/jquery.js" type="text/javascript"></script>
<script src="../jquery/jquery-ui.custom.js" type="text/javascript"></script>
<script src="../jquery/jquery.cookie.js" type="text/javascript"></script>
<link href="../src/skin/ui.dynatree.css" rel="stylesheet" type="text/css">
<script src="../src/jquery.dynatree.js" type="text/javascript"></script>
<!-- Start_Exclude: This block is not part of the sample code -->
<link href="prettify.css" rel="stylesheet">
<script src="prettify.js" type="text/javascript"></script>
<link href="sample.css" rel="stylesheet" type="text/css">
<script src="sample.js" type="text/javascript"></script>
<!-- End_Exclude -->
<!-- Add code to initialize the tree when the document is loaded: -->
<script type="text/javascript">
$(function(){
$("#tree").dynatree({
checkbox: true,
// Override class name for checkbox icon, so rasio buttons are displayed:
//classNames: {checkbox: "dynatree-radio"},
// Select mode 3: multi-hier
selectMode: 3,
children: [
{title: "Item 1", key: "node1"},
{title: "Folder 2", isFolder: true, key: "node2",
children: [
{title: "Sub-item 2.1", key: "node2.1"},
{title: "Sub-item 2.2", key: "node2.2"}
]
},
{title: "Item 3", key: "node3"}
]
});
$("form").submit(function() {
// Serialize standard form fields:
var formData = $(this).serializeArray();
// then append Dynatree selected 'checkboxes':
var tree = $("#tree").dynatree("getTree");
formData = formData.concat(tree.serializeArray());
// and/or add the active node as 'radio button':
if(tree.getActiveNode()){
formData.push({name: "activeNode", value: tree.getActiveNode().data.key});
}
alert("POSTing this:\n" + jQuery.param(formData));
$.post("http://127.0.0.1:8001/submit_data",
formData,
function(response, textStatus, xhr){
alert("POST returned " + response + ", " + textStatus);
}
);
return false;
});
});
</script>
</head>
<body class="example">
<h1>Example: Form</h1>
<p class="description">
This checkbox tree is embedded in a form.
The [Submit] handler serializes the selected tree nodes as if they were
standard checkboxes.<br>
The values are then POSTed to the server (together with the other form
elements).
</p>
<!--
<form action="http://127.0.0.1:8001/submit_data" method="POST">
-->
<form>
Username: <input type="text" name="userName" />
<br>
<textarea name="comment"></textarea>
<br>
<input type="radio" name="rb1" value="foo" checked> Foo
<input type="radio" name="rb1" value="bar"> Bar
<input type="radio" name="rb1" value="baz"> Baz
<br>
<input type="checkbox" name="cb1" value="John" checked>John
<input type="checkbox" name="cb1" value="Paul">Paul
<input type="checkbox" name="cb1" value="George">George
<input type="checkbox" name="cb1" value="Ringo">Ringo
<br>
<!-- The name attribute is used by tree.serializeArray() -->
<div id="tree" name="selNodes">
</div>
<input type="submit" value="Send data">
</form>
<!-- Start_Exclude: This block is not part of the sample code -->
<hr>
<p class="sample-links no_code">
<a class="hideInsideFS" href="http://dynatree.googlecode.com">jquery.dynatree.js project home</a>
<a class="hideOutsideFS" href="#">Link to this page</a>
<a class="hideInsideFS" href="samples.html">Example Browser</a>
<a href="#" id="codeExample">View source code</a>
</p>
<pre id="sourceCode" class="prettyprint" style="display:none"></pre>
<!-- End_Exclude -->
</body>
</html>