Skip to content

Instantly share code, notes, and snippets.

View EzeRangel's full-sized avatar
🤠
Working

Ezequiel Rangel EzeRangel

🤠
Working
View GitHub Profile
@scott2b
scott2b / Twitter Bootstrap Collapsible Accordion Example
Created April 3, 2012 18:21
A less invasive approach to using the collapsible plugin from Twitter Bootstrap. Requires the use of less and a bit of additional javascript.
/*
Twitter Bootstrap is a nice library, but the way they handle markup for styles and plugins is a bit invasive at
times. Since Bootstrap is built with Less CSS anyway, it makes sense to take advantage of Less to cleanup the
markup.
This is an attempt at cleaning up the collapsible accordion example. If you don't like the HTML5 tags, you can
replace them with divs with classes (make the appropriate changes in the less).
One quirk that I know of: if you use the "in" class to indicate a default open article, the first accordion
click will not transition smoothly. I haven't figured out why this is happening, but generally with the
@austinhyde
austinhyde / js-observables-binding.md
Last active August 16, 2023 18:19
Vanilla JavaScript Data Binding

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5

setN(10);