jqwidgets-framework
Version:
jQWidgets is an advanced Angular, Vue, Blazor, React, Web Components, jquery, ASP .NET MVC, Custom Elements and HTML5 UI framework.
80 lines (74 loc) • 4.09 kB
HTML
<html lang="en">
<head>
<title id="Description">Integration of jqxScrollBar with Knockout</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/json2.js"></script>
<script type="text/javascript" src="../../../scripts/knockout-3.0.0.js"></script>
<script type="text/javascript" src="../../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../../jqwidgets/jqxbuttons.js"></script>
<script type="text/javascript" src="../../../scripts/demos.js"></script>
<script type="text/javascript" src="../../../jqwidgets/jqxknockout.js"></script>
<script type="text/javascript" src="../../../jqwidgets/jqxcheckbox.js"></script>
<script type="text/javascript" src="../../../jqwidgets/jqxscrollbar.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var viewModel = function (value, min, max) {
this.value = ko.observable(value);
this.min = ko.observable(0);
this.max = ko.observable(max);
this.validateValue = function () {
if (this.value() > this.max()) this.value(parseFloat(this.max()));
if (this.value() < this.min()) this.value(parseFloat(this.min()));
}
this.setMax = ko.computed({
read: this.max,
write: function (value) {
if (!isNaN(value))
this.max(parseFloat(value)); // Write to underlying storage
if (value < this.min()) this.max(parseFloat(this.min()) + 1);
this.validateValue();
},
owner: this
});
this.setMin = ko.computed({
read: this.min,
write: function (value) {
if (!isNaN(value))
this.min(parseFloat(value)); // Write to underlying storage
if (value > this.max()) this.max(parseFloat(value) + 1);
this.validateValue();
},
owner: this
});
this.setValue = ko.computed({
read: this.value,
write: function (value) {
if (!isNaN(value))
this.value(parseFloat(value)); // Write to underlying storage
this.validateValue();
},
owner: this
});
this.disabled = ko.observable(false);
};
ko.applyBindings(new viewModel(100, 0, 1000));
});
</script>
</head>
<body class='default'>
<div data-bind="jqxScrollBar: {min: min, max: max, value: value, disabled: disabled, width: 400, height: 18}"></div>
<table style='margin-top: 30px; margin-bottom: 10px;'>
<tr><td>Min</td><td><input data-bind="value: setMin" /></td></tr>
<tr><td>Max</td><td><input data-bind="value: setMax" /></td></tr>
<tr><td>Value</td><td><input data-bind="value: setValue" /></td></tr>
</table>
<div data-bind="jqxCheckBox: {checked: disabled, width: '100px'}" style='margin-top: 10px; margin-bottom: 10px;'>Disabled</div>
<div style="position: absolute; bottom: 5px; right: 5px;">
<a href="https://www.jqwidgets.com/" alt="https://www.jqwidgets.com/"><img alt="https://www.jqwidgets.com/" title="https://www.jqwidgets.com/" src="https://www.jqwidgets.com/wp-content/design/i/logo-jqwidgets.png"/></a>
</div>
</body>
</html>