Methods
$(selector) → {object}
jQuery constructor. See https://jquery.com
- Source:
Parameters:
Name | Type | Description |
---|---|---|
selector |
string
|
jQuery selector. |
Returns:
- Type:
-
object
jQuery
dataBind(elem) → {void}
Add/Read private data to a DOM element.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
elem |
object
|
DOM element to bind data to. |
Returns:
- Type:
-
void
Example
var elem = document.getElementById('foo');
// Attach private data to element:
dataBind(elem).someName = { value: 42 };
dataBind(elem)['other-name'] = { value: 43 };
// Read private data from element:
var some = dataBind(elem).someName;
var other = dataBind(elem)['other-name'];
deepExtend(myObj) → {object}
A handy method to (deep) extend an object. The input object is modified.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
myObj |
object
|
Input object. |
Returns:
- Type:
-
object
Example
var one = { foo:1, bar: { a:true, b:false } };
var two = { bar: { a:false } };
// In this case both `ext` and `one` will be the same object.
var ext = deepExtend(one, two);
// To create a fresh copy, pass in an empty object as first arg.
var ext = deepExtend({}, one, two);
// Now `ext` is `{ foo:1, bar: { a:false, b:false } }`
// and `one` is left intact.