Skip to content

Instantly share code, notes, and snippets.

@dpdragnev
Created March 6, 2015 04:39
Show Gist options
  • Save dpdragnev/37cd732ef9d6ac75e1ec to your computer and use it in GitHub Desktop.
Save dpdragnev/37cd732ef9d6ac75e1ec to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/teqegewoyu
<!DOCTYPE html>
<html>
<head>
<link href="http://da7xgjtj801h2.cloudfront.net/2014.2.716/styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="http://da7xgjtj801h2.cloudfront.net/2014.2.716/styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://da7xgjtj801h2.cloudfront.net/2014.2.716/js/kendo.ui.core.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
div { margin: 10px 0; }
</style>
</head>
<body id='body'>
<button data-bind='click: select' class='k-button'>Show Next Name</button>
<div data-bind='text: current'></span>
<script id="jsbin-javascript">
myvar = new kendo.observable ({
current: '',
idx: 0,
words: ['Alec', 'Daniel', 'Cara', 'Wiggie', 'Reggie', 'Charlie'],
select: function() {
myvar.set('current', myvar.words[myvar.idx]);
myvar.idx++;
if (myvar.idx == 6)
myvar.idx = 0;
}
});
kendo.bind($('#body'), myvar);
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<link href="//da7xgjtj801h2.cloudfront.net/2014.2.716/styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="//da7xgjtj801h2.cloudfront.net/2014.2.716/styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
<script src="//code.jquery.com/jquery-1.9.1.min.js"><\/script>
<script src="//da7xgjtj801h2.cloudfront.net/2014.2.716/js/kendo.ui.core.min.js"><\/script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body id='body'>
<button data-bind='click: select' class='k-button'>Show Next Name</button>
<div data-bind='text: current'></span>
</body>
</html></script>
<script id="jsbin-source-css" type="text/css">div { margin: 10px 0; }</script>
<script id="jsbin-source-javascript" type="text/javascript">myvar = new kendo.observable ({
current: '',
idx: 0,
words: ['Alec', 'Daniel', 'Cara', 'Wiggie', 'Reggie', 'Charlie'],
select: function() {
myvar.set('current', myvar.words[myvar.idx]);
myvar.idx++;
if (myvar.idx == 6)
myvar.idx = 0;
}
});
kendo.bind($('#body'), myvar);</script></body>
</html>
div { margin: 10px 0; }
myvar = new kendo.observable ({
current: '',
idx: 0,
words: ['Alec', 'Daniel', 'Cara', 'Wiggie', 'Reggie', 'Charlie'],
select: function() {
myvar.set('current', myvar.words[myvar.idx]);
myvar.idx++;
if (myvar.idx == 6)
myvar.idx = 0;
}
});
kendo.bind($('#body'), myvar);
@dpdragnev
Copy link
Author

Simple Kendo UI MVVM example to teach my 10 year old about MVVM binding :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment