Skip to content

Instantly share code, notes, and snippets.

View ThaNarie's full-sized avatar

Arjan van Wijk ThaNarie

View GitHub Profile
@ThaNarie
ThaNarie / CustomBindingHandler.js
Created October 9, 2012 19:05 — forked from RainerAtSpirit/CustomBindingHandler.js
KnockoutJS, RequireJS and the revealing module pattern
define (['knockout', 'jquery', 'prettyDate', 'metrojs'], function ( ko, $ ) {
"use strict";
// See https://github.com/SteveSanderson/knockout/wiki/Bindings---class
ko.bindingHandlers['class'] = {
'update' : function ( element, valueAccessor ) {
if ( element['__ko__previousClassValue__'] ) {
ko.utils.toggleDomNodeCssClass (element, element['__ko__previousClassValue__'], false);
}
var value = ko.utils.unwrapObservable (valueAccessor ());