Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Atulin/htmxlike

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

htmxlike

HTMLX but in under 1 KB and JSON-friendly.

Keywords

Assume /quote returns a JSON response like

{
    "quote": "Hope is the spark that ignites our dreams.",
    "author": "Riko Tanaka"
}

o-action

Consists of the method and the URL to call. The method is optional, defaulting to GET.

<button o-method="GET /quote" >
    Clickme
</button>

o-ref

Optional parameter to specify the ID of the element to which the received data should be applied. If missing, data is applied to the element itself.

<button o-method="GET /quote" o-ref="quotebox">
    Clickme
</button>

<quote id="quotebox"></quote>

o-prop

Parameter to specify which property of the received object should be applied to the target element.

<button o-method="GET /quote" o-ref="quotebox">
    Clickme
</button>

<quote id="quotebox">
    <p o-prop="quote"></p>
    <cite o-prop="author"></cite>
</quote>

Properties are stringified with String(value) and applied as the .innerText of the target element.

o-class-*

Parameter to specify what classes (if any) should be added to the target element depending on the status of the request.

Attribute Description
o-class-error Request did not return a 2XX status code; request or JSON parsing threw an error.
o-class-loading Added before the request starts; removed when the request finishes.
o-class-success Added when the request finishes successfully.
<button o-method="GET /quote" o-ref="quotebox">
    Clickme
</button>

<quote 
    id="quotebox"
    o-class-error="error"
    o-class-loading="loading"
    o-class-success="success"
>
    <p o-prop="quote"></p>
    <cite o-prop="author"></cite>
</quote>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published