Converse.js渲染到容器中 [英] Converse.js render into a container

查看:113
本文介绍了Converse.js渲染到容器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将Converse.js配置为自定义 div 容器,而不是将它们添加到页面正文中?

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?

推荐答案

是的,你可以写一个 converse.js插件,其中覆盖 insertIntoPage 方法 ChatBoxView

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;
            }
        },
    }

更新:从最近版本的converse.js开始,覆盖的方法是 _ ensureElement 而不是 insertIntoPage

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

这篇关于Converse.js渲染到容器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆