new Hobo(selector, context)
Parameters:
Name | Type | Description |
---|---|---|
selector |
string | The goods - String, Element, Collection. |
context |
element | The Element used to call |
- Source:
Members
-
<static> utils
-
Utility methods used internally by Hobo
- Source:
Methods
-
<static> ajax(config) → {Promise}
-
Perform standar XHR with a native Promise.
dataType can behtml
,json
,jsonp
.Parameters:
Name Type Description config
object The ajax config object
url => string, default: window.location.href
data => object, default: null
dataType => string, default: "html"
method => string, default: "GET"
jsonp => string, default: "callback"
headers => object, default: null- Source:
Returns:
- Type
- Promise
-
addAttr(node, key, value) → {string}
-
Get or Set an attribute(s) on a DOM node
Parameters:
Name Type Description node
element The element to set attribute on
key
string The attribute
value
mixed The value to set
- Source:
Returns:
- Type
- string
-
addClass(classes) → {Hobo}
-
Add one or more classNames to the nodes.
Parameters:
Name Type Description classes
string The space-separated classNames
- Source:
Returns:
- Type
- Hobo
-
append(appendage) → {Hobo}
-
Append the nodes to the DOM
Parameters:
Name Type Description appendage
mixed What to append? Hobo, Element...
- Source:
Returns:
- Type
- Hobo
-
attr(key, value) → {string}
-
Get or Set an attribute(s) on a DOM node
Parameters:
Name Type Description key
string The attribute
value
mixed The value to set
- Source:
Returns:
- Type
- string
-
children() → {Hobo}
-
Gather all child nodes that are NOT text nodes
- Source:
Returns:
- Type
- Hobo
-
closest(selector) → {Hobo}
-
Find the first ancestor element with this selector
Parameters:
Name Type Description selector
string The selector to try and match
- Source:
Returns:
- Type
- Hobo
-
data(key, value) → {mixed}
-
Get / set data values with nodes.
Parameters:
Name Type Description key
string The access key
value
string The value to be stored
- Source:
Returns:
- Type
- mixed
-
detach() → {Hobo}
-
Detach the nodes from the DOM
This method does NOT remove events or data.- Source:
Returns:
- Type
- Hobo
-
each(callback)
-
Make sure Hobo is iterable like an Array
Parameters:
Name Type Description callback
function The method called on each iteration
- Source:
-
eq(i) → {Hobo}
-
Get the element at the index as a Hobo instance.
Parameters:
Name Type Description i
number The indexOf the element
- Source:
Returns:
- Type
- Hobo
-
filter(selector) → {Hobo}
-
Filter out the elements that match the selector.
Parameters:
Name Type Description selector
string The selector to match elements against
- Source:
Returns:
- Type
- Hobo
-
find(selector) → {Hobo}
-
Query into a Hobo instance for new nodes.
Parameters:
Name Type Description selector
string The selector to query for
- Source:
Returns:
- Type
- Hobo
-
first() → {Hobo}
-
Get hobo instance of the first element.
- Source:
Returns:
- Type
- Hobo
-
forEach(callback)
-
Make sure Hobo is iterable like an Array
Parameters:
Name Type Description callback
function The method called on each iteration
- Source:
-
index() → {number}
-
Get the nodes index compared to its DOM siblings.
Possibly this should be its index in the Hobo set?- Source:
Returns:
- Type
- number
-
is(selector) → {boolean}
-
Determine if a node set is this selector.
Parameters:
Name Type Description selector
string The selector to match elements against
- Source:
Returns:
- Type
- boolean
-
last() → {Hobo}
-
Get hobo instance of the last element.
- Source:
Returns:
- Type
- Hobo
-
map(callback)
-
Make sure Hobo is mappable like an Array
Parameters:
Name Type Description callback
function The method called for each element
- Source:
-
next(selector) → {Hobo}
-
Get the next sibling, test against selector
Parameters:
Name Type Description selector
string Optional selector to match
- Source:
Returns:
- Type
- Hobo
-
not(selector) → {Hobo}
-
Filter out elements that are NOT this selector
Parameters:
Name Type Description selector
string The selector to filter out elements
- Source:
Returns:
- Type
- Hobo
-
off(events, callback) → {Hobo}
-
Un-Bind a standard DOM Event.
Parameters:
Name Type Description events
string The event type
callback
function The supplied callback
- Source:
Returns:
- Type
- Hobo
-
on(events, selector, callback) → {Hobo}
-
Bind a standard DOM Event. Honor delegation as a primary.
Parameters:
Name Type Description events
string selector
string callback
function - Source:
Returns:
- Type
- Hobo
-
one(event, selector, callback) → {Hobo}
-
Bind a standard DOM Event only ONE time.
Parameters:
Name Type Description event
string selector
string callback
function - Source:
Returns:
- Type
- Hobo
-
parent(selector) → {Hobo}
-
Get a Hobo instance of the parent node of this instance.
Parameters:
Name Type Description selector
string Optional selector to match
- Source:
Returns:
- Type
- Hobo
-
prepend(prependage) → {Hobo}
-
Append the nodes to the DOM
Parameters:
Name Type Description prependage
mixed What to prepend? Hobo, Element...
- Source:
Returns:
- Type
- Hobo
-
prev(selector) → {Hobo}
-
Get the previous sibling, test against selector
Parameters:
Name Type Description selector
string Optional selector to match
- Source:
Returns:
- Type
- Hobo
-
push(element)
-
Make sure Hobo is pushable like an Array
Parameters:
Name Type Description element
? element1, ..., elementN
- Source:
-
remove() → {Hobo}
-
Remove the nodes from the DOM
This method will remove events and data.- Source:
Returns:
- Type
- Hobo
-
removeAttr(attr) → {Hobo}
-
Remove the specified attribute from each node in the set.
Parameters:
Name Type Description attr
string The attribute to remove
- Source:
Returns:
- Type
- Hobo
-
removeClass(classes) → {Hobo}
-
Remove one or more classNames from the nodes.
Parameters:
Name Type Description classes
string The space-separated classNames
- Source:
Returns:
- Type
- Hobo
-
toggleClass(classes) → {Hobo}
-
Add or remove the specified classNames.
Parameters:
Name Type Description classes
string The space-separated classNames
- Source:
Returns:
- Type
- Hobo
-
trigger(event) → {Hobo}
-
Dispatch a simulated event.
Parameters:
Name Type Description event
string The event to dispatch
- Source:
Returns:
- Type
- Hobo