# model/wires

Source: https://zotonic.com/cotonic/zotonic-models/wires

URI: https://zotonic.com/id/2747

Language: en



model/wires
===========

Connects Cotonic messages to named Zotonic events through the wires script.

post/event/+name
----------------

Topic: `model/wires/post/event/+name`.

The final topic segment names an event registered on the page. The handler calls `z_event(name, msg.payload)`, passing the payload as the event's parameters.

For a named event created by a template wire:

```django
{% wire name="refresh-preview" action={reload} %}
```

Publish its name from JavaScript:

```javascript
cotonic.broker.publish("model/wires/post/event/refresh-preview", {});
```

The resulting behavior depends on the named wire: it may execute browser actions or send a postback to the server. The client command itself has no response and publishes no `model/wires/event` message. Server-side authorization remains the responsibility of the receiving action or delegate.

Implementation
--------------

[JavaScript source](https://github.com/zotonic/zotonic/blob/master/apps/zotonic_mod_wires/priv/lib/js/apps/zotonic-wired.js).

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2747?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/2747?language=en>)
