Skip to content

Action Event Modifiers

Ralf Bitter edited this page Aug 14, 2025 · 3 revisions

The Controller

The View

Calling the Controller Handler from Global JavaScript


This example showing the use of an event modifier has almost the same setup as outlined in Chapter Action Parameters. The difference is that the "Reset Name" button is part of a form.

The Controller

<?lc

put "asynForm,index,name,resetName" into gControllerHandlers


command asynForm
  rigLoaderLoadLibrary "ASYNergy"
end asynForm


command index
  get rigLoadView("asynFormView")
end index


command name
  rigAsynRespond "{{name}}"
end name


command resetName
  local tParamsA
  
  put rigAsynParams() into tParamsA

  if tParamsA[1] is empty then
    put "Chico" into tParamsA[1]
  end if

  rigAsynRespond tParamsA[1], "name"
end resetName

The View

This is almost the same view as in Chapter Action Parameters, except for the form element. The form element of this view, asynFormView.lc, has an asyn:submit directive with a prevent modifier.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
  </head>

  <body>
    <div style="float: left;margin-right: 20px;">
		
      <input asyn:model="name" type="text" id="name">
    </div>
        
    <div>
      <p>Hello <span asyn:mutable="name"></span></p>
    </div>
    
    <div>
      <form action="#" asyn:submit.prevent="resetName('Bingo Bingo')">
			
        <button type="submit">Reset Name</button>
      </form>
			
    </div>

    [[gData["asynergyScript"] ]]
  </body>
</html>

The prevent modifier blocks the default click handling, so that the form action is not executed when the user clicks onto the submit button. Instead, the resetName handler of the asynForm.lc controller is called.

Calling the Controller Handler from Global JavaScript

To call the resetName handler of the revIgniter controller from global JavaScript, use the ASYNergy.emit method, such as:

<script>

  ASYNergy.emit('resetName', 'Bingo Bingo');

</script>

Clone this wiki locally