原创  (小君原创)js轻量级双向绑定插件way.js的使用--前篇

分类: 2015-05-06T22:42:55    2107人阅读   

本来想自己写一个的,结果别人已经写出来的,这叫我情何以堪。

简单绑定 DEMO:

<!DOCTYPE HTML>
<html>
<head>
<title>wayjs demo</title>
<script src="way.min.js"></script>
</head>
<body>
<div>
	  <form way-data="myFormData" way-persistent="true">
    <input type="text" name="name">
    <input type="text" name="age">
    <input type="text" name="gender">
  </form>

Name: <span way-data="myFormData.name"></span>
age: <span way-data="myFormData.age"></span>
gender: <span way-data="myFormData.gender"></span>
</div>
</body>
</html>
获取输入的值 DEMO:
<!DOCTYPE HTML>
<html>
<head>
<title>wayjs demo</title>
<meta charset="UTF-8"/>
<script src="way.min.js"></script>
<script src="jquery-1.7.1.js"></script>
<script type="text/javascript">
	$(function(){
		$('#getModelData').click(function(){
			console.log(way.get("myFormData"));
		});
	});
</script>
</head>
<body>
<div>
  <input type="button" value="获取值" id="getModelData"/>
	  <form way-data="myFormData" way-persistent="true" id="myFormData">
    <input type="text" name="name">
    <input type="text" name="age">
    <input type="text" name="gender">
  </form>
</div>
</body>
</html>
不早了先睡了


分享到: