org.querki.jquery

JQuery

Related Doc: package jquery

trait JQuery extends Object

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 are currently dealing with the messy cases by defining a polymorphic type in package.scala, using the "tor" type-union trick, and then defining a mid-level facade for that method in JQueryTyped. Then we put a primitive "Internal" version of the method in here. As a rule, you should not directly use any methods here named [something]Internal -- they should always have a more precisely-typed version in JQueryTyped.

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.

Annotations
@RawJSType()
Linear Supertypes
Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. JQuery
  2. Object
  3. Any
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. def addClass(func: ThisFunction2[Element, Int, String, String]): JQuery

  5. def addClass(classNames: String): JQuery

    Adds the specified class(es) to each of the set of matched elements.

  6. def afterInternal(content: Any): JQuery

    Annotations
    @JSName( "after" )
  7. def appendInternal(content: Any*): JQuery

    Annotations
    @JSName( "append" )
  8. def appendToInternal(target: Any): JQuery

    Annotations
    @JSName( "appendTo" )
  9. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  10. def attrInternal(attributeName: String, v: Any): JQuery

    Annotations
    @JSName( "attr" )
  11. def attrInternal(attributes: Dictionary[String]): JQuery

    Annotations
    @JSName( "attr" )
  12. def attrInternal(attributeName: String): UndefOr[String]

    Annotations
    @JSName( "attr" )
  13. def change(): JQuery

  14. def change(eventData: Any, handler: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

  15. def change(handler: Function1[JQueryEventObject, Any]): JQuery

  16. def change(handler: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

  17. def change(handler: ThisFunction0[Element, Any]): JQuery

    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.

  18. def children(): JQuery

  19. def children(selector: String): JQuery

    Get the children of each element in the set of matched elements, optionally filtered by a selector.

  20. def click(func: Function0[Any]): JQuery

  21. def click(func: Function1[JQueryEventObject, Any]): JQuery

  22. def click(func: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

  23. def click(func: ThisFunction0[Element, Any]): JQuery

    Bind an event handler to the "click" JavaScript event.

    Bind an event handler to the "click" JavaScript event.

    This is the simpler version, and usually what you want.

  24. def clone(withDataAndEvents: Boolean, deepWithDataAndEvents: Boolean): JQuery

  25. def clone(withDataAndEvents: Boolean): JQuery

  26. def clone(): JQuery

    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.

    Definition Classes
    JQuery → AnyRef
  27. def css(properties: Dictionary[Any]): JQuery

  28. def css(propertyName: String, value: Int): JQuery

  29. def css(propertyName: String, value: String): JQuery

  30. def css(propertyNames: Array[String]): Dictionary[String]

  31. def css(propertyName: String): String

    Get the computed style properties for the first element in the set of matched elements.

  32. def data(): Dictionary[Any]

    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.

  33. def data(key: String): Any

    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.

  34. def data(obj: Dictionary[Any]): JQuery

  35. def data(key: String, value: Any): JQuery

    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" ).

  36. def delay(duration: Int, queueName: String): JQuery

  37. def delay(duration: Int): JQuery

    Set a timer to delay execution of subsequent items in the queue.

  38. def detach(selector: String): JQuery

  39. def detach(): JQuery

    Remove the set of matched elements from the DOM.

  40. def each(func: ThisFunction1[Element, Int, Any]): JQuery

  41. def each(func: ThisFunction0[Element, Any]): JQuery

    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.

  42. def empty(): JQuery

    Remove all child nodes of the set of matched elements from the DOM.

  43. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  44. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  45. def filterInternal(selectorOrFunc: Any): JQuery

    Annotations
    @JSName( "filter" )
  46. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  47. def findInternal(selector: Any): JQuery

    Annotations
    @JSName( "find" )
  48. def first(): JQuery

    Reduce the set of matched elements to the first in the set.

  49. def focus(eventData: Any, func: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

  50. def focus(func: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

  51. def focus(): JQuery

    Bind an event handler to the "focus" JavaScript event, or trigger that event on an element.

  52. def get(): Array[_]

    Retrieve the elements matched by the jQuery object.

  53. def get(index: Int): UndefOr[Element]

    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.

  54. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  55. def hasClass(className: String): Boolean

    Determine whether any of the matched elements are assigned the given class.

  56. def hasOwnProperty(v: String): Boolean

    Definition Classes
    Object
  57. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  58. def height(value: String): JQuery

  59. def height(value: Double): JQuery

    Set the CSS height of every matched element.

  60. def height(): Double

    Get the current computed height for the first element in the set of matched elements.

  61. def hide(duration: Int, easing: String, complete: Function): JQuery

  62. def hide(duration: Int, easing: String): JQuery

  63. def hide(duration: Int, complete: Function): JQuery

  64. def hide(duration: Int): JQuery

  65. def hide(duration: String, easing: String, complete: Function): JQuery

  66. def hide(duration: String, easing: String): JQuery

  67. def hide(duration: String, complete: Function): JQuery

  68. def hide(duration: String): JQuery

  69. def hide(): JQuery

    Hide the matched elements.

  70. def indexInternal(selector: Any): Int

    Annotations
    @JSName( "index" )
  71. def indexInternal(): Int

    Annotations
    @JSName( "index" )
  72. def insertBeforeInternal(selector: Any): JQuery

    Annotations
    @JSName( "insertBefore" )
  73. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  74. def isInternal(selector: Any): Boolean

    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.

    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.

    Annotations
    @JSName( "is" )
  75. def isPrototypeOf(v: Object): Boolean

    Definition Classes
    Object
  76. def keydown(): JQuery

  77. def keydown(eventData: Any, handler: Function1[JQueryEventObject, Any]): JQuery

  78. def keydown(handler: Function1[JQueryEventObject, Any]): JQuery

    Bind an event handler to the "keydown" JavaScript event, or trigger that event on an element.

  79. def keypress(): JQuery

  80. def keypress(eventData: Any, handler: Function1[JQueryEventObject, Any]): JQuery

  81. def keypress(handler: Function1[JQueryEventObject, Any]): JQuery

    Bind an event handler to the "keypress" JavaScript event, or trigger that event on an element.

  82. def keyup(): JQuery

  83. def keyup(eventData: Any, handler: Function1[JQueryEventObject, Any]): JQuery

  84. def keyup(handler: Function1[JQueryEventObject, Any]): JQuery

    Bind an event handler to the "keyup" JavaScript event, or trigger that event on an element.

  85. def length: Int

    The number of elements in the jQuery object.

  86. def map(func: ThisFunction1[Element, Int, Any]): JQuery

  87. def map(func: ThisFunction0[Element, Any]): JQuery

    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.)

  88. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  89. final def notify(): Unit

    Definition Classes
    AnyRef
  90. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  91. def off(event: JQueryEventObject): JQuery

  92. def off(eventsMap: Dictionary[ThisFunction1[Element, JQueryEventObject, Any]]): JQuery

  93. def off(eventsMap: Dictionary[ThisFunction1[Element, JQueryEventObject, Any]], selector: String): JQuery

  94. def off(): JQuery

  95. def off(events: String): JQuery

  96. def off(events: String, selector: String): JQuery

  97. def off(events: String, selector: String, handler: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

    Remove an event handler.

  98. def offset(): JQueryPosition

    Get the current coordinates of the first element in the set of matched elements, relative to the document.

  99. def on(eventsMap: Dictionary[ThisFunction1[Element, JQueryEventObject, Any]]): JQuery

  100. def on(eventsMap: Dictionary[ThisFunction1[Element, JQueryEventObject, Any]], selector: String): JQuery

  101. def on(eventsMap: Dictionary[ThisFunction1[Element, JQueryEventObject, Any]], selector: String, data: Any): JQuery

  102. def on(events: String): JQuery

  103. def on(events: String, turnOff: Boolean): JQuery

  104. def on(events: String, selector: String): JQuery

  105. def on(events: String, selector: String, data: Any): JQuery

  106. def on(events: String, selector: String, data: Any, turnOff: Boolean): JQuery

    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.

  107. def on(events: String, handler: Function1[JQueryEventObject, Any]): JQuery

  108. def on(events: String, handler: ThisFunction0[Element, Any]): JQuery

  109. def on(events: String, handler: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

  110. def on(events: String, selector: String, data: Any, handler: ThisFunction1[Element, JQueryEventObject, Any]): JQuery

    Attach an event handler function for one or more events to the selected elements.

  111. def parent(): JQuery

  112. def parent(selector: String): JQuery

    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.

  113. def parents(): JQuery

  114. def parents(selector: String): JQuery

    Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.

  115. def prependInternal(contents: Any*): JQuery

    Insert content, specified by the parameters, to the beginning of each element in the set of matched elements.

    Insert content, specified by the parameters, to the beginning of each element in the set of matched elements.

    Annotations
    @JSName( "prepend" )
  116. def prop(propertyName: String, func: ThisFunction2[Element, Int, Any, Any]): JQuery

  117. def prop(properties: Dictionary[Any]): JQuery

  118. def prop(propertyName: String, value: Any): JQuery

    Set one or more properties for the set of matched elements.

  119. def prop(propertyName: String): Any

    Get the value of a property for the first element in the set of matched elements.

  120. def propertyIsEnumerable(v: String): Boolean

    Definition Classes
    Object
  121. def remove(childSelector: String): JQuery

  122. def remove(): JQuery

    Remove the set of matched elements from the DOM.

  123. def removeClass(func: ThisFunction2[Element, Int, String, String]): JQuery

  124. def removeClass(classNames: String): JQuery

  125. def removeClass(): JQuery

    Remove a single class, multiple classes, or all classes from each element in the set of matched elements.

  126. def replaceWithInternal(content: Any): JQuery

    Annotations
    @JSName( "replaceWith" )
  127. def scrollTop(value: Double): JQuery

    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.

  128. def scrollTop(): Int

    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.

  129. def show(duration: Int, easing: String, complete: Function): JQuery

  130. def show(duration: Int, easing: String): JQuery

  131. def show(duration: Int, complete: Function): JQuery

  132. def show(duration: Int): JQuery

  133. def show(duration: String, easing: String, complete: Function): JQuery

  134. def show(duration: String, easing: String): JQuery

  135. def show(duration: String, complete: Function): JQuery

  136. def show(duration: String): JQuery

  137. def show(): JQuery

    Hide the matched elements.

  138. def slideDown(duration: Int): JQuery

  139. def slideDown(duration: String): JQuery

  140. def slideDown(): JQuery

    Display the matched elements with a sliding motion.

  141. def slideUp(duration: Int): JQuery

  142. def slideUp(duration: String): JQuery

  143. def slideUp(): JQuery

    Hide the matched elements with a sliding motion.

  144. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  145. def text(func: Function2[Int, String, String]): JQuery

  146. def text(t: String): JQuery

    Set the content of each element in the set of matched elements to the specified text.

  147. def text(): String

    Get the combined text contents of each element in the set of matched elements, including their descendants.

  148. def toArray(): Array[Element]

    Retrieve all the elements contained in the jQuery set, as an array.

  149. def toLocaleString(): String

    Definition Classes
    Object
  150. def toString(): String

    Definition Classes
    AnyRef → Any
  151. def trigger(event: JQueryEventObject): JQuery

  152. def trigger(eventType: String): JQuery

    Execute all handlers and behaviors attached to the matched elements for the given event type.

  153. def val(func: Function2[Int, String, String]): JQuery

  154. def val(value: String): JQuery

  155. def val(value: Array[String]): JQuery

  156. def val(): Dynamic

    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.

  157. def value(func: Function2[Int, String, String]): JQuery

    Annotations
    @JSName( "val" )
  158. def value(value: String): JQuery

    Annotations
    @JSName( "val" )
  159. def value(value: Array[String]): JQuery

    Annotations
    @JSName( "val" )
  160. def value(): Dynamic

    Annotations
    @JSName( "val" )
  161. def valueOf(): Any

    Definition Classes
    Object
  162. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  163. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  164. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  165. def width(value: String): JQuery

  166. def width(value: Double): JQuery

    Set the CSS width of every matched element.

  167. def width(): Double

    Get the current computed width for the first element in the set of matched elements.

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped