The self-written javascript binding model is based on jquery
// Bind the model $. bind ={}; // bind the base $. bind. base = function (get, set) {return function (o) {if (typeof (o )! = 'Undefined') {set (o) ;}; return get ();};};
// Bind the text $. bind. text = function (element, func) {var $ el = element; return $. bind. base (function () {return $ el. text () ;}, function (o) {$ el. text (o); if (typeof (func) = 'function') {func ($ el, o) ;}) ;}; // bind the value $. bind. val = function (element, func) {var $ el = element; return $. bind. base (function () {return $ el. val () ;}, function (o) {$ el. val (o); if (typeof (func) = 'function') {func ($ el, o );};});}; // bind.html = function (element, func) {var $ el = element; return $. bind. base (function () {return cancel.html () ;}, function (o) {cancel.html (o); if (typeof (func) = 'function ') {func ($ el, o );};});};
// Bind bool $. bind. bool = function (element, func) {var $ el = element; var obj = true; return $. bind. base (function () {return obj ;}, function (o) {obj = o; if (typeof (func) = 'function') {func ($ el, o) ;};};}; // add and remove css$.bind.css Class = function (element, css, check, func) {var $ el = element; var obj = true according to bool; return $. bind. base (function () {return obj ;}, function (o) {if (check & obj = o) {return ;}obj = o; if (o) {$ el. addClass (css);} else {$ el. removeClass (css);} if (typeof (func) = 'function') {func ($ el, o );};});}; // hide $. bind. visibility = function (element, check, func) {var $ el = element; var obj = true; return $. bind. base (function () {return obj ;}, function (o) {if (check & obj = o) {return ;}obj = o; if (o) {$ el. show ();} else {$ el. hide () ;}if (typeof (func) = 'function') {func ($ el, o );};});};
// Bind the hidden value $. bind. hide = function (func) {var obj = true; return $. bind. base (function () {return obj ;}, function (o) {obj = o; if (typeof (func) = 'function ') {func (o) ;};};}; // bind an array $. bind. array = function (element, func) {var array = []; var $ el = element; return $. bind. base (function () {return array;}, function (o) {array = o; $ el. empty (); if (typeof (func) = 'function') {$. each (o, funct Ion (I, v) {func ($ el, I, v) ;};}) ;}; // bind object $. bind. obj = function (o, func) {var list = []; var obj ={}; for (var item in o) {var temp ={}; temp. o = item; var temp_obj = o [temp. o]; switch (temp_obj.t) {case 'array': temp. obj = $. bind. array (temp_obj.el, temp_obj.f); break; case 'text': temp. obj = $. bind. text (temp_obj.el, temp_obj.f); break; case 'val': temp. obj = $. bind. val (temp_obj.el, te Mp_obj.f); break; case 'html ': temp. obj = pai.bind.html (temp_obj.el, temp_obj.f); break; case 'bool ': temp. obj = $. bind. bool (temp_obj.el, temp_obj.f); break; case 'hide ': temp. obj = $. bind. hide (temp_obj.f); break; case 'cssclass ': temp. obj = pai.bind.css Class (temp_obj.el, temp_obj.css, temp_obj.ck, temp_obj.f); break; case 'visi': temp. obj = $. bind. visibility (temp_obj.el, temp_obj.ck, temp_obj.f); bre Ak; case 'visibility ': temp. obj = $. bind. visibility (temp_obj.el, temp_obj.ck, temp_obj.f); break; default:} list. push (temp) ;}; return function (o) {if (typeof (o )! = 'Undefined') {obj = o; $. each (list, function (I, v) {v. obj (o [v. o]) ;}); if (typeof (func) = 'function') {func (o) ;};}; return obj ;};};