Members
auto :boolean
- Description:
- The auto attribute of this fragment, toggles automatic behaviour on/off
- Source:
The auto attribute of this fragment, toggles automatic behaviour on/off
Type:
raw :string
- Description:
- The raw representation of this fragment, can be used to set/get the raw value.
- Source:
The raw representation of this fragment, can be used to set/get the raw value.
Type:
Examples
//Get the raw value of a fragment
let fragmentValue = myFragment.raw;
//Set the raw value of a fragment
myFragment.raw = myNewFragmentValue;
(readonly) type :string
- Description:
- The type of this fragment
- Source:
The type of this fragment
Type:
Methods
getDomPath()
- Description:
- Returns a dompath for finding this fragment
- Source:
registerOnAutoChangedHandler(callback)
- Description:
- Register a callback to run when auto attribute changes on fragment
- Source:
Example
Fragment.one("#myFragment").registerOnAutoChangedHandler((fragment, auto)=>{
//Fragment auto attribute changed
});
Parameters:
registerOnClassChangedHandler(callback)
- Description:
- Register a callback to run when the classes of this fragment changes
- Source:
Example
Fragment.one("#myFragment").registerOnClassChangedHandler((classes)=>{
//Some classes changed on this fragment
});
Parameters:
registerOnFragmentChangedHandler(callback)
- Description:
- Register a callback to be run when this fragments content changes.
- Source:
Example
Fragment.one("#myFragment").registerOnFragmentChangedHandler((context)=>{
//Fragment has changed
});
Parameters:
registerOnFragmentUnloadedHandler(callback)
- Description:
- Register a callback to run when this fragment is unloaded
- Source:
Example
Fragment.one("#myFragment").registerOnFragmentUnloadedHandler(()=>{
//Fragment is unloaded
});
Parameters:
registerOnTextDeletedHandler(callback)
- Description:
- Register a callback to run when text is deleted from this fragment
- Source:
Example
Fragment.one("#myFragment").registerOnTextDeletedHandler((position, value)=>{
//Text "value" has been deleted from this fragment at "position"
});
Parameters:
registerOnTextInsertedHandler(callback)
- Description:
- Register a callback to run when text is inserted into this fragment
- Source:
Example
Fragment.one("#myFragment").registerOnTextInsertedHandler((position, value)=>{
//Text "value" has been inserted into this fragment at "position"
});
Parameters:
(async, abstract) require(optionsopt) → {*}
- Description:
- Require this fragment and return the result. What require does depends on what type of fragment it is.
- Source:
Example
let result = await Fragment.one("#myFragment").require()
Parameters:
Name |
Type |
Attributes |
Description |
options |
json
|
<optional>
|
The options to pass to require |
Returns:
result of the require action
-
Type
-
*
unRegisterOnAutoChangedHandler(callback)
- Description:
- Unregister a callback handler
- Source:
Parameters:
unRegisterOnFragmentChangedHandler(callback)
- Description:
- Unregister a callback handler
- Source:
Parameters:
unRegisterOnFragmentUnloadedHandler(callback)
- Description:
- Unregister a callback handler
- Source:
Parameters:
unload()
- Description:
- Tell this fragment to unload itself
- Source:
Example
Fragment.one("#myFragment").unload();
- Description:
- Create a fragment of the given type.
If no Fragment is registered for the given type, null is returned.
- Source:
Example
let myJSFragment = Fragment.create("text/javascript");
Parameters:
Name |
Type |
Description |
type |
string
|
the type of fragment to create |
Returns:
the created fragment, or null
-
Type
-
Fragments.Fragment
- Description:
- Finds all fragments based on a given query
- Source:
Example
let fragments = Fragment.find(".someClass");
Parameters:
Name |
Type |
Description |
query |
string
|
cQuery
|
Array
|
Node
|
The query used to find fragments. Can be a css selector, a cQuery object, a dom element or an array of dom elements. |
Returns:
The found fragments
-
Type
-
Array.<Fragments.Fragment>
- Description:
- Returns the first fragment that is found from the given query
This is the equivalent of taking the first result of Fragment.find(query)
- Source:
Example
let myFragment = Fragment.one("#myFragment");
Parameters:
Name |
Type |
Description |
query |
string
|
cQuery
|
Array
|
Node
|
The query used to find fragments. Can be a css selector, a cQuery object, a dom element or an array of dom elements. |
Returns:
- the found fragment, or null if none could be found
-
Type
-
Fragments.Fragment
Type Definitions
autoChangedCallback(fragment, auto)
- Source:
Parameters:
Name |
Type |
Description |
fragment |
Fragments.Fragment
|
The fragment |
auto |
boolean
|
The new value of auto |
fragmentChangedCallback(context)
- Source:
Parameters:
Name |
Type |
Description |
context |
Fragment
|
Object
|
The context that called the callback |
fragmentClassChangedCallback(classes)
- Source:
Parameters:
Name |
Type |
Description |
classes |
Array.<string>
|
The classes that changed |
fragmentUnloadedCallback(fragment)
- Source:
Parameters:
textDeletedCallback(position, value)
- Source:
Parameters:
Name |
Type |
Description |
position |
number
|
The position where the text was deleted |
value |
string
|
The value of deleted text |
textInsertedCallback(position, value)
- Source:
Parameters:
Name |
Type |
Description |
position |
number
|
The position where the text was inserted |
value |
string
|
The value of inserted text |