.. raw:: html
.. _`events-API`: Events emitted by converse.js ============================= .. contents:: Table of Contents :depth: 2 :local: .. note:: see also :ref:`listen-grouping` above. Event Types ----------- Here are the different events that are emitted: cachedRoster ~~~~~~~~~~~~ The contacts roster has been retrieved from the local cache (`sessionStorage`). ``converse.listen.on('cachedRoster', function (event, items) { ... });`` See also the `roster` event further down. callButtonClicked ~~~~~~~~~~~~~~~~~ When a call button (i.e. with class .toggle-call) on a chat box has been clicked. ``converse.listen.on('callButtonClicked', function (event, connection, model) { ... });`` chatBoxInitialized ~~~~~~~~~~~~~~~~~~ When a chat box has been initialized. Relevant to converse-chatview.js plugin. ``converse.listen.on('chatBoxInitialized', function (event, chatbox) { ... });`` chatBoxOpened ~~~~~~~~~~~~~ When a chat box has been opened. Relevant to converse-chatview.js plugin. ``converse.listen.on('chatBoxOpened', function (event, chatbox) { ... });`` chatRoomOpened ~~~~~~~~~~~~~~ When a chat room has been opened. Relevant to converse-chatview.js plugin. ``converse.listen.on('chatRoomOpened', function (event, chatbox) { ... });`` chatBoxClosed ~~~~~~~~~~~~~ When a chat box has been closed. Relevant to converse-chatview.js plugin. ``converse.listen.on('chatBoxClosed', function (event, chatbox) { ... });`` chatBoxFocused ~~~~~~~~~~~~~~ When the focus has been moved to a chat box. Relevant to converse-chatview.js plugin. ``converse.listen.on('chatBoxFocused', function (event, chatbox) { ... });`` chatBoxToggled ~~~~~~~~~~~~~~ When a chat box has been minimized or maximized. Relevant to converse-chatview.js plugin. ``converse.listen.on('chatBoxToggled', function (event, chatbox) { ... });`` connected ~~~~~~~~~ After connection has been established and converse.js has got all its ducks in a row. ``converse.listen.on('connected', function (event) { ... });`` contactRequest ~~~~~~~~~~~~~~ Someone has requested to subscribe to your presence (i.e. to be your contact). ``converse.listen.on('contactRequest', function (event, user_data) { ... });`` contactRemoved ~~~~~~~~~~~~~~ The user has removed a contact. ``converse.listen.on('contactRemoved', function (event, data) { ... });`` contactStatusChanged ~~~~~~~~~~~~~~~~~~~~ When a chat buddy's chat status has changed. ``converse.listen.on('contactStatusChanged', function (event, buddy) { ... });`` contactStatusMessageChanged ~~~~~~~~~~~~~~~~~~~~~~~~~~~ When a chat buddy's custom status message has changed. ``converse.listen.on('contactStatusMessageChanged', function (event, data) { ... });`` disconnected ~~~~~~~~~~~~ After converse.js has disconnected from the XMPP server. ``converse.listen.on('disconnected', function (event) { ... });`` initialized ~~~~~~~~~~~ Once converse.js has been initialized. ``converse.listen.on('initialized', function (event) { ... });`` See also `pluginsInitialized`_. logout ~~~~~~ The user has logged out. ``converse.listen.on('logout', function (event) { ... });`` messageSend ~~~~~~~~~~~ When a message will be sent out. ``converse.listen.on('messageSend', function (event, messageText) { ... });`` noResumeableSession ~~~~~~~~~~~~~~~~~~~ When keepalive=true but there aren't any stored prebind tokens. ``converse.listen.on('noResumeableSession', function (event) { ... });`` pluginsInitialized ~~~~~~~~~~~~~~~~~~ Once all plugins have been initialized. This is a useful event if you want to register event handlers but would like your own handlers to be overridable by plugins. In that case, you need to first wait until all plugins have been initialized, so that their overrides are active. One example where this is used is in `converse-notifications.js