Skip to content

Instantly share code, notes, and snippets.

@loyalchow
loyalchow / jquery.db.js
Created September 29, 2011 19:43
Simple class to data-bind mappings for Knockoutjs using jQuery
(function($){
$.db = function() {
// any form inputs, data-bind based on value:name
// if input type=text, use valueUpdate: 'afterkeydown'
// if input type=checkbox or radio, use checked:name
// if textarea, use value:name
$('input.db, textarea.db').each(function() {
var $this = $(this);
if (!this.name) return;
switch(this.type) {
/* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
*/
// Inspired by base2 and Prototype
(function(){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing)
this.Class = function(){};
/*
dependencies:
- knockout-1.3.0.js
- simple-class.js
- amplify.js
*/
(function() {
window.__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };