Constructor
(protected) new Element(elementnon-null)
Parameters:
| Name | Type | Description |
|---|---|---|
element |
HTMLElement |
Extends
Members
(protected, constant, non-null) app :jrt.App
Reference to the app instance, just for convenience.
Type:
- Overrides:
(constant, non-null) element :HTMLElement
The HTML element represented by this instance.
Type:
- HTMLElement
Methods
(static) a(hrefopt, nullable, content, classNameopt, nullable, titleopt, nullable) → (non-null) {HTMLAnchorElement}
Creates a HTMLAnchorElement and sets its href attribute and content.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
href |
string |
<optional> <nullable> |
The link's URL. |
content |
string | Node | !Array.<(string|!Node)> | null | ||
className |
string |
<optional> <nullable> |
Space-separated class list (optional). |
title |
string |
<optional> <nullable> |
Element title (optional). |
Returns:
- Type
- HTMLAnchorElement
(static) button(actionopt, nullable, content, classNameopt, nullable, titleopt, nullable) → (non-null) {HTMLButtonElement}
Creates a HTMLButtonElement with type "button".
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string |
<optional> <nullable> |
The button's |
content |
string | Node | !Array.<(string|!Node)> | null | ||
className |
string |
<optional> <nullable> |
Space-separated class list. |
title |
string |
<optional> <nullable> |
Element title (optional). |
Returns:
- Type
- HTMLButtonElement
(static) create(tagName, content, classNameopt, nullable, titleopt, nullable) → (non-null) {HTMLElement}
Creates an HTML element with the given tag name, content and optional class.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
tagName |
string | The element's tag name (in lowercase). |
|
content |
string | Node | !Array.<(string|!Node)> | null | ||
className |
string |
<optional> <nullable> |
Space-separated class list (optional). |
title |
string |
<optional> <nullable> |
Element title (optional). |
Returns:
- Type
- HTMLElement
(static) createFragment(html) → (non-null) {DocumentFragment}
Creates a DocumentFragment from an HTML string or an array of HTML nodes.
Parameters:
| Name | Type | Description |
|---|---|---|
html |
string | !Array.<(string|!Node)> |
Returns:
- Type
- DocumentFragment
(static) get(id) → (nullable) {HTMLElement}
Replacement for document.getElementById that returns HTMLElement
instead of Element.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
Returns:
- Type
- HTMLElement
(static) input(type, nameopt, nullable, value, classNameopt, nullable, titleopt, nullable) → (non-null) {HTMLInputElement}
Creates a HTMLInputElement and sets its type, name
and value attributes.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
type |
string | The input type. |
|
name |
string |
<optional> <nullable> |
The input name. |
value |
string | number | null | The initial value. |
|
className |
string |
<optional> <nullable> |
Space-separated class list (optional). |
title |
string |
<optional> <nullable> |
Element title (optional). |
Returns:
- Type
- HTMLInputElement
(static) label(htmlFornullable, content, classNameopt, nullable, titleopt, nullable) → (non-null) {HTMLLabelElement}
Creates a HTMLLabelElement element.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
htmlFor |
string |
<nullable> |
The labeled form control's id. |
content |
string | Node | !Array.<(string|!Node)> | null | ||
className |
string |
<optional> <nullable> |
Space-separated class list (optional). |
title |
string |
<optional> <nullable> |
Element title (optional). |
Returns:
- Type
- HTMLLabelElement
(static) option(value, labelopt, nullable, classNameopt, nullable) → (non-null) {HTMLOptionElement}
Creates a HTMLOptionElement and sets its value attribute
and text content.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
value |
string | number | The value for this option. |
|
label |
string |
<optional> <nullable> |
If omitted, 'value' is used as the option's label. |
className |
string |
<optional> <nullable> |
Space-separated class list (optional). |
Returns:
- Type
- HTMLOptionElement
(static) select(name, classNameopt, nullable, titleopt, nullable) → (non-null) {HTMLSelectElement}
Creates a HTMLSelectElement and sets its name attribute.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | The select name. |
|
className |
string |
<optional> <nullable> |
Space-separated class list (optional). |
title |
string |
<optional> <nullable> |
Element title (optional). |
Returns:
- Type
- HTMLSelectElement
(static) textarea(nameopt, nullable, valueopt, nullable, rowsopt, classNameopt, nullable, titleopt, nullable) → (non-null) {HTMLTextAreaElement}
Creates a HTMLTextAreaElement and sets its name, value
and rows attributes.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string |
<optional> <nullable> |
The text area's name. |
value |
string |
<optional> <nullable> |
The initial value. |
rows |
number |
<optional> |
The number of lines (2 by default). |
className |
string |
<optional> <nullable> |
Space-separated class list (optional). |
title |
string |
<optional> <nullable> |
Element title (optional). |
Returns:
- Type
- HTMLTextAreaElement
(protected) handleEvent(enon-null, labelnullable)
This method is called when an event registered with listenToEvent
is triggered.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
e |
Event | The event object. |
|
label |
string |
<nullable> |
The label specified when registering the event. |
(protected) ignoreEvent(eventType, elementopt, nullable)
Stops listenig to the specified event type on the specified element.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
eventType |
string | The event type to listen to. |
|
element |
Element |
<optional> <nullable> |
The HTML element to stop listening to. Defaults to this element. |
(protected) listenToEvent(eventType, elementopt, nullable, labelopt, nullable, useCaptureopt)
Sets this object as the event listener for the specified event type and element.
The handleEvent method is called when the event occurs.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
eventType |
string | The event type to listen to. |
|
element |
Element |
<optional> <nullable> |
The HTML element to listen to. Defaults to this element. |
label |
string |
<optional> <nullable> |
Optional label passed to the event handler. |
useCapture |
boolean |
<optional> |
(protected) processResponse(reqnon-null, status, responsenullable)
Implement this method to process the response received after a call to sendRequest.
The response data type depends on the responseType property specified in the request.
The response status can be "success", "server-error", "type-error" (when the specified response type does not match the received data), "error" (if there is a connection error), "timeout" or "offline". Note that the "offline" status is not reliable in all devices, so an "error" status may be received when offline.
The default implementation does nothing.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
req |
jrt.AjaxRequest | The request object. |
|
status |
string | The response status (see method description). |
|
response |
jrt.AjaxResponse |
<nullable> |
The server response. This will be null on error or timeout. |
- Overrides:
(protected) sendRequest(reqnon-null)
Sends an asynchronous AJAX request to the URL specified in req'. The supported
methods are "GET" (the default), "POST", "PUT", "PATCH", "DELETE" and "HEAD".
The response will be passed to processResponse.
The expected response type can be specified with the responseType
property in the specified request ("json" by default).
Parameters:
| Name | Type | Description |
|---|---|---|
req |
jrt.AjaxRequest |
- Overrides:
Throws:
-
If any of the request parameters is invalid.
- Type
- Error