ganelon.web.widgets documentation

action

(action tag action-name params attributes & body)
Generate action tag using hiccup.core/html for a supplied tag. If *widget-id* scope is present, it is appended to params map.
The generated element has :onclick handler which invokes Ganelon.performButtonAction function.

Example:

(action :span "test1"  {:x 1} {:class "btn"} [:strong "Invoke"])
;=>"<span class="btn" onclick="return Ganelon.performButtonAction(this, 'test1', 'x=1');"><strong>Invoke</strong></span>"

action-button

(action-button action-name params attributes & body)
Generate action link using hiccup.core/html. If *widget-id* scope is present, it is appended to params map - unless explictly provided.
The generated element has :onclick handler which invokes Ganelon.performButtonAction function.

Example:

(action-button "test1"  {:x 1} {:class "btn"} [:strong "Invoke"])
;=>"<button class="btn" href="#" onclick="return Ganelon.performButtonAction(this, 'test1', 'x=1');"><strong>Invoke</strong></button>"

action-form

(action-form action-name params attributes & body)
Generate form which on submit invokes designated action.

If widget-id in scope is present, it is added to parameters map - unless explictly provided.

(action-form "test1" {:y 1} {:class "well"} [:input {:type "submit"}])
;=> "<form class=\"well\" method=\"POST\" onsubmit=\"return Ganelon.performFormAction(this, 'test1', 'y=1&amp;widget-id=%23');\"><input type=\"submit\" /></form>"

action-loader-button

(action-loader-button action-name params attributes & body)
Just as action-button, but with with-ajax-loader applied to attributes.

(action-loader-button "test1" {:x 1} {:class "btn"} [:strong "Invoke"])
"<button class=\"btn\" data-loading-text=\"&lt;img src='/ganelon/img/loading.gif'/&gt;\" href=\"#\" onclick=\"return Ganelon.performButtonAction(this, 'test1', 'x=1');\"><strong>Invoke</strong></button>"

current-widget-id

(current-widget-id)
Return current widget id.

Example:

(with-id (str "<p>Hello " (current-widget-id) "</p>"))
;=> "<p>Hello 6a70fd73-a39f-423e-9fe0-3339ea75376a</p>"

with-ajax-loader

(with-ajax-loader attributes)
Enhance attributes with Bootstrap's data-loading-text attribute set to  '<img src='/ganelon/img/loading.gif'/>'.

Example:

(action-link "test1" {:x 1} (with-ajax-loader {:class "btn"}) [:strong "Invoke"])
"<a class=\"btn\" data-loading-text=\"&lt;img src='/ganelon/img/loading.gif'/&gt;\" href=\"#\" onclick=\"return Ganelon.performButtonAction(this, 'test1', 'x=1');\"><strong>Invoke</strong></a>"

with-div

macro

(with-div & rest)
Generate random widget UID, and wrap its body with a DIV tag. Establishes widget-id scope, which can
be used for example by action links to pass current widget id.

Wraps & rest with hiccup.core/html for more consise code. If hiccup is not used/necessary, with-id or with-set-id macros
should be used.

Example:

(with-div
  [:h4 "Hello"])

with-el

macro

(with-el el & rest)
Generate random widget UID, and wrap its body with a tag of a supplied type. Establishes widget-id scope, which can
be used for example by action links to pass current widget id.

Wraps & rest with hiccup.core/html for more consise code. If hiccup is not used/necessary, with-id or with-set-id macros
should be used.

Example:

(with-el :h1 "Hello")
;=> "<h1 id="b6d8d958-fb2e-4e29-94ba-bfb0a11f006b">Hello</h1>"

with-id

macro

(with-id & rest)
Establishes widget-id scope, which can be used for example by action links to pass current widget id.

Example:

(with-id (str "<p>Hello " (current-widget-id) "</p>"))
;=> "<p>Hello 6a70fd73-a39f-423e-9fe0-3339ea75376a</p>"

with-set-id

macro

(with-set-id id & rest)
Establishes widget-id scope for a supplied id,
which can be used for example by action links to pass current widget id.

Example:

(with-set-id "test1" (str "<p>Hello " (current-widget-id) "</p>"))
;=> "<p>Hello test1</p>"

with-span

macro

(with-span & rest)
Generate random widget UID, and wrap its body with a SPAN tag. Establishes widget-id scope, which can
be used for example by action links to pass current widget id.

Wraps & rest with hiccup.core/html for more consise code. If hiccup is not used/necessary, with-id or with-set-id macros
should be used.

Example:

(with-span  "Hello")

with-widget

macro

(with-widget id & rest)
Take widget UID as parameter, and wrap its body with a DIV tag. Establishes widget-id scope, which can
be used for example by action links to pass current widget id.

Wraps & rest with hiccup.core/html for more consise code. If hiccup is not used/necessary, with-id or with-set-id macros
should be used.

Example:

(with-id "widget1"
  [:h4 "Hello"])