Converse.js render into a container

让人想犯罪 __ 提交于 2019-12-06 06:17:46

问题


Is it possible to configure Converse.js to render it's boxes into custom div containers instead of adding them to the body of the page?


回答1:


Yes, you can do this by writing a converse.js plugin in which you override the insertIntoPage method of ChatBoxView.

Refer to the plugin documentation I linked to above. In short, it would look something like this:

// The following line registers your plugin.
converse_api.plugins.add('myplugin', {

    overrides: {
        // If you want to override some function or a Backbone model or
        // view defined inside converse, then you do that under this
        // "overrides" namespace.    
        ChatBoxView: {
            insertIntoPage: function (type, status_message, jid) {
                // XXX Your custom code comes here.
                // The standard code looks as follows:
                this.$el.insertAfter(converse.chatboxviews.get("controlbox).$el);
                return this;
            }
        },
    }

UPDATE: Since recent versions of converse.js, the method to override is instead _ensureElement and not insertIntoPage.



来源:https://stackoverflow.com/questions/32475755/converse-js-render-into-a-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!