Converse.js 渲染到容器中
Converse.js render into a container
是否可以配置 Converse.js 以将其框呈现到自定义 div
容器中而不是将它们添加到页面正文中?
是的,你可以通过编写 ChatBoxView
的 converse.js plugin in which you override the insertIntoPage 方法来做到这一点。
参考我上面链接的插件文档。简而言之,它看起来像这样:
// 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
.
是否可以配置 Converse.js 以将其框呈现到自定义 div
容器中而不是将它们添加到页面正文中?
是的,你可以通过编写 ChatBoxView
的 converse.js plugin in which you override the insertIntoPage 方法来做到这一点。
参考我上面链接的插件文档。简而言之,它看起来像这样:
// 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
.