title: Dynamically updating a TinyMCE 4 ListBox
body: <p>I'm trying to modify the TinyMCE 4 "link" plugin to allow users to select content from ListBox elements that are dynamically updated by AJAX requests.</p>
  
  <p>I'm creating the ListBox elements in advance of editor.windowManager.open(), so they are initially rendered properly. I have an onselect handler that performs the AJAX request, and gets a response in JSON format.</p>
  
  <p>What I need to do with the JSON response is to have it update another ListBox element, replacing the existing items with the new results.</p>
  
  <p>I'm baffled, and the documentation is terribly unclear. I don't know if I should replace the entire control, or delete items and then add new ones. I don't know if I need to instantiate a new ListBox control, or render it to HTML, etc.</p>
  
  <p>Basically, I have access to the original rendered ListBox (name: "module"} with </p>
  
  <p><code>win.find('#module');</code></p>
  
  <p>I have the new values from the AJAX request:</p>
  
  <p><code>var data = tinymce.util.JSON.parse(text).data;</code></p>
  
  <p>And I've tried creating a new Control configuration object, like</p>
  
  <pre><code>newCtrlconfig = {
      type: 'listbox',
      label: 'Class',
      values: data
  };
  </code></pre>
  
  <p>but I wouldn't know how to render it, much less have it replace the existing one.</p>
  
  <p>I tried</p>
  
  <p><code>var newList = tinymce.ui.Factory.create(newCtrlconfig);</code></p>
  
  <p>and then</p>
  
  <p><code>newList.renderHtml()</code></p>
  
  <p>but even then, the rendered HTML did not contain any markup for the items. And examining these objects is just frustrating: there are "settings", "values", "_values", "items" all of which will happily store my values, but it isn't even clear which of them will work.</p>
  
  <p>Since it's a ListBox and not a simple SELECT menu, I can't even easily use the DOM to manipulate the values.</p>
  
  <p>Has anyone conquered the TinyMCE ListBox in 4.x?</p>