Documentation / Tutorials / SPA

Event: Click - interact with server

/ SPA / Event: Click - interact with server

Click on the button will send the data to the server and update the element data with the recieved result.

  1. Front side button: (Click event)
    //** Attach N number of attributes **//
    <button
    bind="click"
    axn="route.run"
    route_ajax="[aw2.get module.slug /].whatever-template-name"
    class="btn btn-xs btn-primary"
    attribute1="value1"
    attribute2="value2"
    >Click Event</button>
  2. HTML element to show the server response:
    <div class='xyz-element'>Reply content will be placed here</div>
  3. Server side template where the posted data will be processed and result send back to server:
    [aw2.template whatever-template-name]
    //** Processing **//
    <template axn="selector.update" selector='.xyz-element' get='me.html'>
    <div>
    This is the reply text recieved from the server
    [aw2.get request dump=true /]
    </div>
    </template>
    [/aw2.template]
Categories
Most Popular

Leave a Reply

Your email address will not be published.