Skip to content

Global JavaScript Events

Ralf Bitter edited this page Aug 13, 2025 · 13 revisions

Introduction

Passing (Model, Action) Parameters

Passing a (Model) Value

Passing Values of Checkboxes or Radio Buttons


Introduction

You can fire ASYNergy events from JavaScript like:

<script>

    ASYNergy.emit('foo');

</script>

This fires an event like asyn:model="foo" or asyn:click="foo" and calls the revIgniter handler "foo". Of course, the HTML must contain a "mutable" element with an attribute like (in this case) asyn:mutable="foo" and a model or an action like:

<button asyn:click="foo">Update me</button>

Following the corresponding revIgniter handler:

command foo
  
  rigAsynRespond "-" & the secs & "-"

end foo

Passing (Model, Action) Parameters

You can send parameters with an event emission.

<script>

    ASYNergy.emit('foo', 'bar,baz');

</script>

This assumes that there is an element with an ASYNergy attribute with the same parameters in the attribute value.

<button asyn:click="foo('bar','baz')">Update me</button>

On the revIgniter side, the ASYNergy library function rigAsynParams() returns these parameters as an array.

command foo
  local tParamsA
  
  put rigAsynParams() into tParamsA
  
  rigAsynRespond "-" & the secs & "-", , tParamsA
end foo

Passing a (Model) Value

You can send values like "models" do:

<script>

	ASYNergy.emit('name', '', 'Jane Doe');

</script>

The corresponding HTML element could look like:

<input asyn:model="name" type="text">

The revIgniter ASYNergy library function rigAsynElemData() returns this value:

command name
	local tName
	
	put rigAsynElemData("name") into tName
		
	rigAsynRespond tName
end name

Passing Values of Checkboxes or Radio Buttons

There is a fourth event parameter. Its argument is a boolean value used for checkboxes or radio buttons that have the corresponding ASYNergy attribute value.

<script>

	ASYNergy.emit('name', '', 'Jane Doe', true);

</script>

To identify a specific radio button, use "model" parameters:

<input type="radio" name="myRadio" value="1" asyn:model="radio('radioA')"  checked="checked" />
<input type="radio" name="myRadio" value="2" asyn:model="radio('radioB')"  />

Add this parameter to the emit function:

<script>

	ASYNergy.emit('radio', 'radioB', '', true);

</script>

Clone this wiki locally