Subclassing woes
How assigning to $ before making a subclass isn't working
by danheberden
HTML
<div id="accordion">
<h3><a href="#">Section 1</a></h3>
<div>
<p>content 1</p>
</div>
<h3><a href="#">Section 2</a></h3>
<div>
<p>content 2</p>
</div>
<h3><a href="#">Section 3</a></h3>
<div>
<p>content 3</p>
</div>
<h3><a href="#">Section 4</a></h3>
<div>
<p>content 4</p>
</div>
</div>
<pre id="out">
</pre>
JavaScript
// assign something to $
$.somethingRandom = "omg my jqueries";
// make our subclass
$sub = $.subclass();
console.log( '$ test' );
console.log( '$.somethingRandom: ', $.somethingRandom );
console.log( '$sub.somethingRandom: ', $sub.somethingRandom );
// so those root functions you like to you? Forget about 'em
console.log( '\n', '$ function' );
console.log( '$.each: ', $.each );
console.log( '$sub.each: ', $sub.each );
// This fails!:
/*$sub.each([1,2], function() {
console.log( this + ':', this );
});*/