Rerender Okta Custom Login Widget


#1

I am rendering the custom login widget with this code:

    signIn.renderEl({
          el: '#widget-container'
        }, function success(res) {
          if (res.status === 'SUCCESS') {
        });

The widget renders successfully however I need to switch between two custom widgets since I have two different Okta orgs that I need to dynamically log in to.
In order to rerender the log in widget with a different signIn variable I recursively delete all elements in the widget-container id:

    var myNode = document.getElementById("widget-container");
          while (myNode.firstChild) {
            myNode.removeChild(myNode.firstChild);
          }

However when I try to render the widget again using the same code as the first one only one element gets created and nothing else. How can I rerender the whole thing?


#2

Have you tried remove?


#3

Hi Tom, thanks I did not realize there was more to the API. signIn.remove() before rerendering it worked for me.