jqwidgets-framework
Version:
jQWidgets is an advanced jQuery, Angular, React, ASP .NET MVC, Custom Elements and HTML5 UI framework.
54 lines (49 loc) • 2.54 kB
HTML
<html lang="en">
<head>
<title id='Description'>In this sample is illustrated how to save and load the jqxDropDownList's selection using cookies. This will allow you to keep the selection when the page is reloaded.</title>
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1 minimum-scale=1" />
<script type="text/javascript" src="../../scripts/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="../../scripts/demos.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
</head>
<body>
<div id='content'>
<script type="text/javascript">
$(document).ready(function () {
var url = "../sampledata/customers.txt";
// prepare the data
var source =
{
datatype: "json",
datafields: [
{ name: 'CompanyName' },
{ name: 'ContactName' }
],
id: 'id',
url: url,
async: false
};
var dataAdapter = new $.jqx.dataAdapter(source);
var index = $.jqx.cookie.cookie("jqxDropDownList_jqxWidget");
if (undefined == index) index = 0;
$("#jqxWidget").jqxDropDownList({ selectedIndex: index, source: dataAdapter, displayMember: "ContactName", valueMember: "CompanyName", width: 200, height: 25});
// subscribe to the select event.
$("#jqxWidget").on('select', function (event) {
// save the index in cookie.
$.jqx.cookie.cookie("jqxDropDownList_jqxWidget", event.args.index);
});
});
</script>
<div id='jqxWidget'>
</div>
</div>
</body>
</html>