button

Makes a button with an action attached.

This is an easy way to make a button and attach one or more actions or a postback.

For example:

{% button text="Click me" action={alert text="Hello Word!"} %}

This show a button with the text “Click me”. When clicked it will trigger the alert action, showing an alert message with the text “Hello World!”.

Another example:

{% button text="Postback" postback={my_postback arg1=1 arg2=2} %}

When clicked it will call the event/2 function in the controller that served the page. The function will be called as:

event(#postback{message={mypostback, [{arg1,1}, {arg2,2}]},
    trigger=TriggerId, target=TargetId}, Context)

Where TriggerId and TargetId are both the HTML id of the button.

button accepts the following arguments:

ArgumentDescriptionExample
textThe text on the button, defaults to “Submit”text=”click me”
postbackAn event sent to the delegate or the resource serving the page.postback=”hello”
tagThe type of HTML tag that will be created. Defaults to “button”.tag=”a”
delegateThe name of the erlang module to be called for handling the postback.delegate=”myresource”
actionThe action to be triggered when the button is clicked. There can be more than one action argument.action=\{show target=”msg”\}
idId of the button.id=#submit
classThe css class of the button. This argument can be repeated to add multiple classes.class=”submit”
styleThe css style of the button.style=”color: #fc0”
tabindexThe value for the tabindex property.tabindex=1
typeThe type attribute of the button.type=”submit”
titleThe title attribute of the button.title=”click to submit”
disabledThe disabled attribute of the button, set to true or false. When the button is disabled then the class “disabled” id added to the class list.disabled=true
hrefThe href attribute of the button if tag “a” is used. Defaults to “#”.href=”/foobar”

Edit on GitHub