Ivan
Ivan

Reputation: 895

TokBox: is there way to recreate video window?

When creating session, we passing element's id to replace with video window. But if element were removed from DOM tree, can we re-bind session to another element?

Upvotes: 1

Views: 86

Answers (1)

aiham
aiham

Reputation: 3614

There is no way to rebind a publisher or subscriber to a different element after it's already been initialised.

Instead you should create a container that you provide to the publisher/subscriber and then you can append and move that container to anywhere in the DOM as you like.

Eg:

const pubContainer = document.createElement('div');
const publisher = OT.initPublisher(pubContainer);
session.publish(publisher);
document.getElementById('A').appendChild(pubContainer);

Then later:

pubContainer.parentElement.removeChild(pubContainer);
document.getElementById('B').appendChild(pubContainer);

Upvotes: 1

Related Questions