• 依赖于JQ
  • 01_页面值-页面值绑定.html
  • 02_List绑定多个相同模型.html
  • 0201_先set,再DOm添加。再get.html
  • 03_绑定多个不同模型.html
  • 04_继承03用类.方法名的形式.html
  • 05_返回给定的DOM元素的范围.html
  • 06_大写小写反写主要英文.html
  • 07_List绑定多个模型-删除部分模型.html
  • 09_01_DOM方法.html
  • 09_02_data方法.html
  • 09_03_localStorage方法.html
  • 09_04_Bind方法.html
  • 09_05_其他方法.html

JQ.js    way.js

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="../Scripts/way.js"></script>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
</head>
<body>
<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>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>重复一个DOM元素的值可以遍历的方式。js的传递数据。</title>
<script src="../Scripts/way.js"></script>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function () {
way.set("some.list", [
{ name: "Pierre", age: 23, phone: "13390907878" },
{ name: "Paul", age: 24, phone: "13390907878" },
{ name: "Jacques", age: 25, phone: "13390907878" }
]);
});
</script> </head>
<body>
<form>
<div>自己的div</div>
<div way-repeat="some.list">
<span way-data="name"></span>
<span way-data="age"></span>
<span way-data="phone"></span>
</div> <!-- 使用下面的展现方式, 可以直接使用 way-scope=[] 类似下标的去访问。
<div way-scope="some.list">
<div way-scope="0">
0 - <span way-data="name">Pierre</span>
</div>
<div way-scope="1">
1 - <span way-data="name">Paul</span>
</div>
<div way-scope="2">
2 - <span way-data="name">Jacques</span>
</div>
</div>
-->
</form>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>重复一个DOM元素的值可以遍历的方式。js的传递数据。</title>
<script src="../Scripts/way.js"></script>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function () {
way.set("some.list", [
{ name: "Pierre", age: 23, phone: "13390907878" },
{ name: "Paul", age: 24, phone: "13390907878" },
{ name: "Jacques", age: 25, phone: "13390907878" }
]); });
function diannimei() {
var html = '';
html = "<div way-scope='1'><span way-data=name'>关亚君</span><span way-data='age'>25</span><span way-data='phone'>18330908989</span></div>";
$(".nidaye").append(html);
}
</script> </head>
<body>
<form>
<div>自己的div</div>
<div class="nidaye" way-repeat="some.list">
<span way-data="name"></span>
<span way-data="age"></span>
<span way-data="phone"></span>
</div>
<a href="#" onclick="diannimei()">点点</a>
<!-- 使用下面的展现方式, 可以直接使用 way-scope=[] 类似下标的去访问。
<div way-scope="some.list">
<div way-scope="0">
0 - <span way-data="name">Pierre</span>
</div>
<div way-scope="1">
1 - <span way-data="name">Paul</span>
</div>
<div way-scope="2">
2 - <span way-data="name">Jacques</span>
</div>
</div>
-->
</form>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>[way-scope] attribute</title>
<script src="../Scripts/way.js"></script>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function () {
way.set("someScope", { with: { something: "hello", name: "张三", age: "23", note: "测试" }, nation: { where: "中国", Address: "北京" } })
});
</script>
</head>
<body>
<div way-scope="someScope">
<div way-scope="with">
<div way-data="something"></div>
<div way-data="name"></div>
<div way-data="note"></div>
<!-- Will render "hello" -->
</div>
<div way-scope="nation">
<div way-data="where"></div>
<div way-data="Address"></div>
<!-- Will render "hello" -->
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>[way-scope-break] attribute</title>
<script src="../Scripts/way.js"></script>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function () {
way.set("someScope", { with: { something: "hello" } })
});
</script>
</head>
<body>
<div way-scope="someScope">
<div way-scope-break="true">
<div way-data="someScope.with.something"></div>
<!-- Will render "hello" -->
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="../Scripts/way.js"></script>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function () {
var dd = way.dom("#someDIV").scope();
alert(dd);
//someScope.with
});
</script>
</head>
<body>
<div way-scope="someScope">
<div way-scope="with">
<div way-data="something" id="someDIV"></div>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="../Scripts/way.js"></script>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function () {
way.set("someData", "hello")
});
</script>
<style type="text/css">
tr td {
border: 2px solid red;
}
</style>
</head> <body>
<div way-data="someData" way-transform="uppercase"></div>
<table style="border: 2px solid red;" >
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td>uppercase</td>
<td>Sets a string to uppercase</td>
<td>"hello" becomes "HELLO"</td>
</tr>
<tr>
<td>lowercase</td>
<td>Sets a string to lowercase</td>
<td>"HELLO" becomes "hello"</td>
</tr>
<tr>
<td>reverse</td>
<td>Reverses a string</td>
<td>"hello" becomes "olleh"</td>
</tr>
</tbody>
</table>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>移出部分模型,展现。</title>
<script src="../Scripts/way.js"></script>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function () {
way.set("some.list", ["I", "am", "list"]);
});
</script>
</head>
<body>
<div way-data="some.list.0"></div>
<!--<div id="clickToRemove" way-action-remove="some.list.2"></div>
<div id="clickToPush" way-action-push="some.list"></div>-->
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="../Scripts/way.js"></script>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function () { //1.way.dom(element).toStorage(options) Stores the element's value to the in-store memory.
way.dom("#someForm").toStorage() //2.way.dom(element).fromStorage(options) Sets the element's value from the stored one.设置从存储一个元素的值。
way.dom("#someForm").fromStorage() //3.way.dom(element).toJSON(options) 返回一个JSON解析数据的
way.dom("#someForm").toJSON() //4.way.dom(element).fromJSON(data, options) 设置元素的值从任何数据(json)。
way.dom("#someForm").fromJSON({ name: "John Doe" }) //5.way.dom(element).getValue() 返回一个JSON结构,其中包含DOM元素的值。
way.dom("#someForm").getValue() //6.way.dom(element).setValue(value, options) 设置元素的值从任何数据(json)。
way.dom("#someForm").setValue({ name: "John Doe" }) //7.way.dom(element).setDefault(force) 设置一个元素的默认值。默认情况下,只有DOM元素的值设置为默认值。其绑定值在数据存储不变。通过[force]参数如果你需要强制设置内存值数据元素的默认值。
way.dom("#someForm").setDefault() //8.way.setDefaults(force) 设置所有绑定DOM元素的默认值。
way.setDefaults() //9.way.dom(element).getOptions() 返回 the list of the ["way-"] 选择标记DOM元素。
way.dom("#someForm").getOptions() });
</script>
</head>
<body>
way.dom(element).toStorage(options)
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Data methods</title>
<script src="../Scripts/way.js"></script>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function () {
way.set("some.path", "bonjour!"); //1.way.get(selector) 返回值的数据储存在一个给定的路径名。
way.get("some.path");
// "bonjour" //2.way.set(selector, value, options)保存的数据在内存中指定的路径名。
way.set("some.path", "bonjour!"); //3.way.remove(selector, options) 删除的数据存储在一个给定的路径名。
way.remove("some.path");
way.get("some.path");
// undefined //4.way.clear(options) 清除所有的数据。
way.clear();
way.get();
// {}
});
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="../Scripts/way.js"></script>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function () { //1.way.backup() 保存在方式存储数据。js localStorage的数据存储。
way.backup(); //2.way.restore() Restores the data saved in localStorage. Called on $(document).ready by default (can be changed with global options).恢复的数据保存在本地文件。呼吁美元(文档)。准备在默认情况下(与全球选项可以改变)。
way.restore(); });
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="../Scripts/way.js"></script>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function () { //1.way.registerBindings()
//Triggers a scan of the DOM to find and save the elements with the [way-data] attribute, that will be bound with some data.
//触发扫描的DOM找到并保存(数据)的元素属性,用一些数据。
way.registerBindings() //2.way.updateBindings(selector)
//Sets the value of all the DOM elements binded to a data selector with their values in way.js' datastore. If omitted, all (excluding write-only's and omitted) DOM elements with a "way-data=" attribute will be refreshed.
//集所有DOM元素的值绑定到数据选择器的方式与他们的价值观。js的数据存储。如果省略,所有(不含只写和省略)DOM元素与“数据= "属性将刷新。
way.updateBindings("formData.name") });
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="../Scripts/way.js"></script>
<script src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function () {
//一、Repeat methods
//1.way.registerRepeats()
//Triggers a scan of the DOM to find and save the elements with the [way-repeat] attribute, that will be bound with some data.
//触发扫描的DOM找到并保存(way-repeat)的元素属性,用一些数据。
way.registerRepeats() //2.way.updateRepeats(selector)
//Triggers a refresh of the repeat elements with their respective data.
//触发器的刷新重复元素与各自的数据。
way.updateRepeats("somethingToBeLooped") //二、Watcher methods
//1.way.watch(selector, callback[value])
//给定值的变化。
way.watch("some.data", function (value) {
console.log("Data has been updated to value: " + value);
}); //2.way.watchAll(callback[selector, value])
//Watches all changes in way.js' datastore. way.watchAll(function (selector, value) {
console.log("The data " + selector + " has been changed.", value);
});
});
</script>
</head>
<body>
</body>
</html>

前后台json数据绑定——way.JS的更多相关文章

  1. JSON字符串和JS对象之间的转换

    JSON字符串和JS对象之间的转换 1 json字符串转换为js对象 1.1 标准json格式字符串转换为Js对象  JSON字符串 str JSON.parse(str) eval(str) eva ...

  2. (转)JSON数据格式和js操作json总结

    原:http://niutuku.com/tech/javaScript/273643.shtml JSON数据格式和js操作json总结 来源:niutuku.com |         vince ...

  3. arguments.callee 调用函数自身用法----JSON.parse()和JSON.stringify()前端js数据转换json格式

    arguments.callee 调用函数自身用法 arguments.callee 在哪一个函数中运行,它就代表哪个函数. 一般用在匿名函数中. 在匿名函数中有时会需要自己调用自己,但是由于是匿名函 ...

  4. json,json对象以及js对象字面量的区别

    从定义看: json:一种数据交换格式 json对象:js的一个内置对象,拥有JSON.stringify()和JSON.parse()两个方法 js对象字面量:封闭在花括号对({})中的一个对象的零 ...

  5. ajax返回json时,js获取类型,是字符串类型

    ajax向php服务端请求,并返回json串给前端. js发现得到的返回值的类型是字符串,不能直接取json对象属性,需要JSON.parse(). 怎么解决呢? 这需要在php返回json时,加上一 ...

  6. express 项目前后台公用样式 /static/js/bootstrap.min.js

    express  项目前后台公用样式 /static/js/bootstrap.min.js

  7. 使用JSON语法创建JS对象(重要)

    JS对象的键值可以加单引号或者不加或者加双引号 JSON语法提供了一种更简单的方式来创建对象,可以避免书写函数,也可避免用new关键字,可以直接创建一个JS对象,使用一个花括号,然后将每个属性写成&q ...

  8. js中json数据简单处理(JSON.parse()和js中嵌套html)

    js中json数据简单处理(JSON.parse()和js中嵌套html) 一.总结 1.html中嵌套js:<script>js代码</script> 2.js中嵌套html ...

  9. 浅谈JSON与与JS相关的JSON函数

    本文内容主要引用在微信公众号上看到的一片文章,因为自己对Json了解不是很深入,所以就整理出这篇博文与大家分享! 一. JSON是一种格式,基于文本,优于轻量,用于交换数据 1.一种数据格式 数据的传 ...

随机推荐

  1. Maven_profile_使用profile配置不同环境的properties(实践)

    配置方法分为以下几个步骤: 1.配置profiles节点(pom.xml) 2.配置build节点(pom.xml)--如果不配置该节点则无法找到profile中的properties属性值,并且配置 ...

  2. ssh中org.springframework.orm.hibernate4.support.OpenSessionInViewFilter的作用及配置

     org.springframework.orm.hibernate4.support.OpenSessionInViewFilter 是Spring为我们解决Hibernate的Session的关闭 ...

  3. UIDynamic - 推动行为: UIPushBehavior

    用途: 从一个点移动到另外一个点; 相关属性: mode : UIPushBehaviorModeContinuous  //推移模式 angle : setAngle  //推移角度 magnitu ...

  4. Angular作用域的层级概念(scope)

    首先引入 angular 的根作用域:$rootScope ng-app:定义了angualr的作用域 ng-controller:定义了控制器 $scope定义了视图与控制器之间的纽带,而scope ...

  5. New blog

    New blog //域名还没备案_(:з」∠)_

  6. php常用数组函数小结

    count函数 作用:计算数组中元素的个数或对象的属性个数 返回值: 数组或者对象, 返回数组的单元个数或者对象的属性个数 Null,返回0 非数组,也非NULL,通通返回1 <?php $ar ...

  7. 基于 BinaryReader 的高效切割TXT文件

    日常工作中免不了要面对一些文件的操作.. 但是如果是日志文件..动辄上G的..处理起来就不那么轻松随意了.. 尤其文件还很多的时候.. 这个时候就会用到大文件切割.. 下边贴出的示例是实验了一个 10 ...

  8. visio二次开发——图纸解析

    (转发请注明来源:http://www.cnblogs.com/EminemJK/) visio二次开发的案例或者教程,国内真的非常少,这个项目也是花了不少时间来研究visio的相关知识,困难之所以难 ...

  9. Codeforces #261 D

    Codeforces #261 D D. Pashmak and Parmida's problem time limit per test 3 seconds memory limit per te ...

  10. 升级到 PHP-7 遇到的坑 及 经验分享

    注意:上面这张图是QQ群网友分享的,图中提到的“被移除的函数”,call_user_func 和 call_user_func_array 在 PHP-7.0 的正式版中是可用的,也许是当时的 测试版 ...