jQuery two way bindings(双向数据绑定插件)
jQuery two way bindings
https://github.com/petersirka/jquery.bindings
这是一个简单的jQuery双向绑定库。 此插件将HTML元素和模型连接起来。 对web开发是一个小型的威力巨大的加农炮。
Simple jQuery two way bindings. This plugin joins HTML elements with a model and in reverse. This plugin is a little big cannon for the web development.
- CLICK HERE - jComponent
- easy to use
- minified only 11 kB (without GZIP compression)
- great functionality
- great use
- works with jQuery 1.9+
- works in IE 7+
- DEMO EXAMPLE
具体例子见:
http://source.858project.com/jquery-bindings-demo.html
工作方式:
根据data-model属性,连接HTML元素和js对象。
data-model的值是js对象的属性名。
在常规控件 INPUTS 类 SELECTS类 和 Textareas 控件使用双向绑定生效; 这些控件值被修改, 则模型(js对象的值被更新)。
How does it works?
- plugin connects a JavaScript object with HTML elements according to data-model attribute
- data-model must contain object property name
- in INPUTS, SELECTS and TEXTAREAS plugin uses two way bindings
- model is updated when is changed value in a INPUT/SELECT/TEXTAREA or manually
DEMO CODE
HTML attributes:
<div id="container" data-name="my-model-1">
<div><input type="text" data-model="property" /></div>
<div data-model="property"></div>
<div data-model="property.next.property"></div>
<div data-model="created" data-format="your-custom-format"></div>
<div data-model="tags" data-custom="your-custom-identificator"></div>
<div data-model="html" data-encode="false"></div>
</div>
- data-name="{String}" is a container name
- data-encode="{Boolean}" enable HTML encoding/decoding string (default: true)
- data-format="{String}" calls $.bindings.format() delegate
- data-custom="{String}" calls $.bindings.custom() delegate
$.bindings('create')(model, [template]);
Create bindings.
$('#form').bindings('create')({ firstname: 'Peter', lastname: 'Širka' });
// or (XHR)
$('#form').bindings('create')({ firstname: 'Peter', lastname: 'Širka' }, '/my-form.html');
// or (HTML)
$('#form').bindings('create')({ firstname: 'Peter', lastname: 'Širka' }, '<input type="text" data-model="firstname" /><span>your firstname: <b data-model="first-name"></b></span>');
// or (SELECTOR)
$('#form').bindings('create')({ firstname: 'Peter', lastname: 'Širka' }, '#template-selector');
jQuery two way bindings(双向数据绑定插件)的更多相关文章
- 双向数据绑定---AngularJS的基本原理学习
Angular JS (Angular.JS) 是一组用来开发Web页面的框架.模板以及数据绑定和丰富UI组件.它支持整个开发进程,提供web应用的架构,无需进行手工DOM操作. AngularJS非 ...
- jQuery.my – 实时的复杂的双向数据绑定
jQuery.my 这个插件用于实时双向数据绑定.它发生变异给出的数据源对象,反映了用户与用户界面之间的相互作用.jQuery.my 提供了全面的验证,条件格式,复杂的依赖关系,运行形式结构操作. 马 ...
- 双向数据绑定(angular,vue)
最近github上插件项目更新了关于双向数据绑定的实现方式,关于angular和vue. angular众所周知是使用的脏检查($dirty).一开始大家会认为angular开启了类似setInter ...
- angularJs:双向数据绑定
示例1 <!DOCTYPE html> <html ng-app> <head> <meta charset="UTF-8" /> ...
- 利刃 MVVMLight 3:双向数据绑定
上篇我们已经了解了MVVM的框架结构和运行原理.这里我们来看一下伟大的双向数据绑定. 说到双向绑定,大家比较熟悉的应该就是AngularJS了,几乎所有的AngularJS 系列教程的开篇 ...
- JavaScript实现简单的双向数据绑定
什么是双向数据绑定 双向数据绑定简单来说就是UI视图(View)与数据(Model)相互绑定在一起,当数据改变之后相应的UI视图也同步改变.反之,当UI视图改变之后相应的数据也同步改变. 双向数据绑定 ...
- Angularjs1.X进阶笔记(1)—两种不同的双向数据绑定
一. html与Controller中的双向数据绑定 html-Controller的双向数据绑定,在开发中非常常见,也是Angularjs1.x的宣传点之一,使用中并没有太多问题. 1.1数据从ht ...
- Vue双向数据绑定原理分析(转)
add by zhj: 目前组里使用的是前端技术是jQuery + Bootstrap,后端使用的Django,Flask等,模板是在后端渲染的.前后端没有分离,这种做法有几个缺点 1. 模板一般是由 ...
- 第217天:深入理解Angular双向数据绑定的原理
一.理解angular双向数据绑定 双向绑定是新的前端框架中频繁出现的一个新词汇,也是mvvm的核心原理.angularjs五条核心信念中的数据驱动,便是由双向绑定进行完成. 那么什么是双向绑定,下面 ...
随机推荐
- squid详解(正向代理、透明代理、反向代理)
squid http://www.squid-cache.org/ --官方网址 squid软件主要有两大应用:1,代理上网(正向代理,透明代理) 2,网站静态页面缓存加速(反向代理) 三种代理类型: ...
- Gym - 100989F
You must have heard about Agent Mahone! Dr. Ibrahim hired him to catch the cheaters in the Algorithm ...
- docker 使用指南
Compose is a tool for defining and running multi-container Docker applications. With Compose, you us ...
- CF集萃1
因为cf上一堆水题,每个单独开一篇博客感觉不太好,就直接放一起好了. CF1096D Easy Problem 给定字符串,每个位置删除要代价.求最小代价使之不含子序列"hard" ...
- APP reset.css
html { box-sizing: border-box; } * { user-select: none; -webkit-tap-highlight-color: rgba(255,255,25 ...
- Maven初窥门径
Maven项目对象模型,可以使用一小段描述来管理项目的构建,报告和文档的软件项目管理工具. 安装 下载地址:http://maven.apache.org/download.cgi 下载解压,我将它放 ...
- Hibernate4
内容简介:1.使用log4j的日志存储,2.一对一关系,3.二级缓存 1 整合log4j(了解) l slf4j 核心jar : slf4j-api-1.6.1.jar .slf4j是 ...
- 完美解决windows+ngnix+phpcgi自动退出的问题
[摘要]在windows下搭建nginx+php环境时,php-cgi.exe会经常性的自动关闭退出,本文介绍通过使用xxfpm进程管理器管理php-cgi.exe. php-cgi.exe在wind ...
- (BFS 二叉树) leetcode 515. Find Largest Value in Each Tree Row
You need to find the largest value in each row of a binary tree. Example: Input: 1 / \ 3 2 / \ \ 5 3 ...
- File的创建
package cn.lijun.demo3; import java.io.File; import java.io.IOException; // 创建文件功能 如果文件已经存在 不再创建 pub ...