Remove elements from the set of matched elements.
Create a new jQuery object with elements added to the set of matched elements.
Add the previous set of elements on the stack to the current set, optionally filtered by a selector.
Adds the specified class(es) to each of the set of matched elements.
Insert content, specified by the parameter, after each element in the set of matched elements.
Register a handler to be called when Ajax requests complete.
Register a handler to be called when Ajax requests complete with an error.
Attach a function to be executed before an Ajax request is sent.
Register a handler to be called when the first Ajax request begins.
Register a handler to be called when all Ajax requests have completed.
Attach a function to be executed whenever an Ajax request completes successfully.
Perform a custom animation of a set of CSS properties.
Insert content, specified by the parameter, to the end of each element in the set of matched elements.
Insert every element in the set of matched elements to the end of the target.
Shorthand for get(x), lifted from scalajs-jquery
Shorthand for get(x), lifted from scalajs-jquery
Set an attribute for the set of matched elements.
Get the value of an attribute for the first element in the set of matched elements.
Get the value of an attribute for the first element in the set of matched elements.
Note that this returns UndefOr -- it is entirely legal for this to return undefined if the attribute is not present, and that causes things to crash if it is not UndefOr.
Insert content, specified by the parameter, before each element in the set of matched elements.
Attach a handler to an event for the elements.
Bind an event handler to the "blur" JavaScript event, or trigger that event on an element.
Bind an event handler to the "change" JavaScript event, or trigger that event on an element.
Bind an event handler to the "change" JavaScript event, or trigger that event on an element.
NOTE: the jQuery documentation is very fuzzy on this point, but implies in an example that "this" gets set appropriately.
Get the children of each element in the set of matched elements, optionally filtered by a selector.
Remove from the queue all items that have not yet been run.
Bind an event handler to the "click" JavaScript event, or trigger that event on an element.
Bind an event handler to the "click" JavaScript event, or trigger that event on an element.
This is the simpler version, and usually what you want.
Create a deep copy of the set of matched elements.
Create a deep copy of the set of matched elements.
Note that this requires an override because Scala.Object declares a clone() method which is entirely unrelated.
For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
Get the children of each element in the set of matched elements, including text and comment nodes.
Get the computed style properties for the first element in the set of matched elements.
Calling .data() with no parameters retrieves all of the values as a JavaScript object.
Calling .data() with no parameters retrieves all of the values as a JavaScript object. This object can be safely cached in a variable as long as a new object is not set with .data(obj). Using the object directly to get or set values is faster than making individual calls to .data() to get or set each value.
Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.
Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. Undefined if that key is not set.
Store arbitrary data associated with the matched elements.
Store arbitrary data associated with the matched elements.
undefined is not recognised as a data value. Calls such as .data( "name", undefined ) will return the corresponding data for "name", and is therefore the same as .data( "name" ).
Bind an event handler to the "dblclick" JavaScript event.
Set a timer to delay execution of subsequent items in the queue.
Execute the next function on the queue for the matched elements.
Remove the set of matched elements from the DOM.
Iterate over a jQuery object, executing a function for each matched element.
Iterate over a jQuery object, executing a function for each matched element.
Note that we do not bother with the full jQuery signature, since the "element" parameter simply matches "this".
You can stop the loop from within the callback function by returning false. Otherwise, the return value is irrelevant.
Remove all child nodes of the set of matched elements from the DOM.
End the most recent filtering operation in the current chain and return the set of matched elements to its previous state.
Reduce the set of matched elements to the one at the specified index.
Display the matched elements by fading them to opaque.
Hide the matched elements by fading them to transparent.
Adjust the opacity of the matched elements.
Display or hide the matched elements by animating their opacity.
Reduce the set of matched elements to those that match the selector or pass the function's test.
Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.
Stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements.
Reduce the set of matched elements to the first in the set.
Bind an event handler to the "focus" JavaScript event, or trigger that event on an element.
Bind an event handler to the "focusin" event.
Bind an event handler to the "focusout" event.
Retrieve the elements matched by the jQuery object.
Retrieve one of the elements matched by the jQuery object.
Retrieve one of the elements matched by the jQuery object.
If the value of index is out of bounds - less than the negative number of elements or equal to or greater than the number of elements - it returns undefined.
Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.
Determine whether any of the matched elements are assigned the given class.
Set the CSS height of every matched element.
Get the current computed height for the first element in the set of matched elements.
Hide the matched elements.
Bind a single handler to the matched elements, to be executed when the mouse pointer enters or leaves the elements.
Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.
Set the HTML contents of every matched element.
Get the HTML contents of the first element in the set of matched elements.
Search for a given element from among the matched elements.
Get the current computed inner height (including padding but not border) for the first element in the set of matched elements.
Get the current computed inner width (including padding but not border) for the first element in the set of matched elements.
Insert every element in the set of matched elements after the target.
Insert every element in the set of matched elements before the target.
Note that this overload doesn't precisely match the jQuery documentation; we elide the redundant Element param, since you have Element as the this parameter.
Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.
A string containing the jQuery version number.
Bind an event handler to the "keydown" JavaScript event, or trigger that event on an element.
Bind an event handler to the "keypress" JavaScript event, or trigger that event on an element.
Bind an event handler to the "keyup" JavaScript event, or trigger that event on an element.
Reduce the set of matched elements to the final one in the set.
The number of elements in the jQuery object.
Load data from the server and place the returned HTML into the matched element.
Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.
Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.
For Scala code, it is often more convenient to use the mapElems() extension function.
Within the callback function, this refers to the current DOM element for each iteration. The function can return an individual data item or an array of data items to be inserted into the resulting set.
If a js.Array is returned, the elements inside the array are inserted into the set. If the function returns null or undefined, no element will be inserted. (Note the implication: this doesn't quite match the usual Scala semantics of map() -- there is a flatten component as well.)
Bind an event handler to the "mousedown" JavaScript event, or trigger that event on an element.
Bind an event handler to the "mouseenter" JavaScript event, or trigger that event on an element.
Bind an event handler to the "mouseleave" JavaScript event, or trigger that event on an element.
Bind an event handler to the "mousemove" JavaScript event, or trigger that event on an element.
Bind an event handler to the "mouseout" JavaScript event, or trigger that event on an element.
Bind an event handler to the "mouseover" JavaScript event, or trigger that event on an element.
Bind an event handler to the "mouseup" JavaScript event, or trigger that event on an element.
Get the immediately following sibling of each element in the set of matched elements.
Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.
Get all following siblings of each element in the set of matched elements, optionally filtered by a selector.
Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed.
Remove an event handler.
Get the current coordinates of the first element in the set of matched elements, relative to the document.
Get the closest ancestor element that is positioned.
Attach an event handler function for one or more events to the selected elements.
Attach an event handler function for one or more events to the selected elements.
This version of the signature allows you to pass in "false" as the handler. This is kind of magical in jQuery -- it is shorthand for a function that just does "return false", which stops propagation on the event. Note that true is *not* a legal value, only false.
Attach an event handler function for one or more events to the selected elements.
Attach an event handler function for one or more events to the selected elements.
Note that this contains overloads for up to 2 "extra" parameters to the handler, but the number is potentially unlimited. If we ever care about more, we could add them.
IMPORTANT: this first signature allows you to specify a sub-selector, and some data to pass. There data parameter is *not* optional -- you must pass something in order for the compiler to pick it up! (At least, put in js.undefined there.) For example, something like:
$("body").on("click", ".element", js.undefined, { (elem:Element, evt:JQueryEventObject) => {...} )
We can't write jQuery's (String, String, ThingFunction1) version of the signature here, because it conflicts with the (String, String, Any) version further down, which does something very different. (jQuery is sometimes too clever for its own good.)
So remember to pass something for the data parameter, in order to get the compiler to do the right thing. If you don't, your function *will* match the (String, String, Any) version of the signature, but it won't work correctly.
Attach a handler to an event for the elements.
Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin.
Get the current computed width for the first element in the set of matched elements, including padding, border, and optionally margin.
Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
TBD: is the parameter really a Selector, or just a String? The JQuery API docs are unclear.
Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.
Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object.
Get the current coordinates of the first element in the set of matched elements, relative to the offset parent.
Insert content, specified by the parameters, to the beginning of each element in the set of matched elements.
Insert every element in the set of matched elements to the beginning of the target.
Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector.
Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector.
Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object.
Return a Promise object to observe when all actions of a certain type bound to the collection, queued or not, have finished.
Set one or more properties for the set of matched elements.
Get the value of a property for the first element in the set of matched elements.
Add a collection of DOM elements onto the jQuery stack.
Show the queue of functions to be executed on the matched elements.
Specify a function to execute when the DOM is fully loaded.
Remove the set of matched elements from the DOM.
Remove an attribute from each element in the set of matched elements.
Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
Remove a previously-stored piece of data.
Remove a property for the set of matched elements.
Replace each target element with the set of matched elements.
Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed.
Bind an event handler to the "resize" JavaScript event, or trigger that event on an element.
Bind an event handler to the "scroll" JavaScript event, or trigger that event on an element.
Get the current horizontal position of the scroll bar for the first element in the set of matched elements.
Set the current vertical position of the scroll bar for each of the set of matched elements.
Set the current vertical position of the scroll bar for each of the set of matched elements.
Note that this intentionally takes Double -- while you usually want to set it to an Int, there are occasions when being able to take a Double (that is, a full JS Number) is convenient in code.
Get the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element.
Bind an event handler to the "select" JavaScript event, or trigger that event on an element.
Encode a set of form elements as a string for submission.
Encode a set of form elements as an array of names and values.
Hide the matched elements.
Get the siblings of each element in the set of matched elements, optionally filtered by a selector.
Reduce the set of matched elements to a subset specified by a range of indices.
Display the matched elements with a sliding motion.
Display or hide the matched elements with a sliding motion.
Hide the matched elements with a sliding motion.
Stop the currently-running animation on the matched elements.
Bind an event handler to the "submit" JavaScript event, or trigger that event on an element.
Set the content of each element in the set of matched elements to the specified text.
Get the combined text contents of each element in the set of matched elements, including their descendants.
Retrieve all the elements contained in the jQuery set, as an array.
Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument.
Execute all handlers and behaviors attached to the matched elements for the given event type.
Execute all handlers attached to an element for an event.
Remove a previously-attached event handler from the elements.
Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.
Shorthand modifier, lifted from scalajs-jquery.
Shorthand modifier, lifted from scalajs-jquery.
Get the value of this JQuery.
Get the value of this JQuery.
"value" is highly context-dependent. The signature is loose because it can return a String, a Number (?) or an Array, depending on circumstances. See the extension methods in JQueryExtensions for more strongly-typed versions that you can use when you expect a specific return type.
Set the CSS width of every matched element.
Get the current computed width for the first element in the set of matched elements.
Wrap an HTML structure around each element in the set of matched elements.
Wrap an HTML structure around all elements in the set of matched elements.
Wrap an HTML structure around the content of each element in the set of matched elements.
A facade for the main jQuery object.
This is a reimplementation, very loosely based on the existing scalajs-jquery. It aims to be much more strongly and precisely typed, while being as literal a translation of the functionality of jQuery as possible. It is intentionally pretty close to scalajs-jquery, and many files can be switched over by simply switching the import, but compatibility has *not* been a priority, and a modest number of functions have changed in breaking ways. (This is one reason why I treated this as a rewrite rather than as an evolution of the existing library.)
TODO: as of this writing, this is *quite* incomplete; I am only adding functions as I use them, and at least half of them are currently missing. Pull requests are greatly welcomed. In particular, we are lacking many overloads -- I've added some of them, but many jQuery functions have a considerable number of potential overloads.
Many parameters are polymorphic. We often use | (type union) to define these, but | and UndefOr don't mix, so we often have to spell things out in more detail. Also, you can't use a js.Function or js.ThisFunction in a | expression, because it interferes with the compiler's implicit conversion from a Scala function to a js.Function. Note that there are several common unions such as Selector defined in package.scala.
Things are also often spelled out more explicitly than you might expect, because Scala restricts us to one overload per method with default parameters; this limits our usage of UndefOr.
We don't necessarily spell out every possible overload here, although we've made a serious effort to make every version of the JS calls possible. In some cases, we only have versions that involve some extra parameters. If you find yourself really wanting an overload that takes fewer parameters, pull requests are welcome.
NOTE: discussion on scalajs Gitter, 1/28/15, says that facades should *return* Any, but *take* js.Any *if* the Javascript is going to process the value in any way. This is the guiding principle here.
Also: when a facade function takes a property bag, if it is understood to be name/value pairs in JS, declare it as js.Dictionary[T]. Often, we can constrain T; if not, just put js.Any, and it is at least explicit that it is name/value pairs.
Long-deprecated functions are, by and large, simply omitted. Please see the jQuery documentation to see what to use instead.