More about putting a TE in a JQuery tabs widget tab

More about putting a TE in a JQuery tabs widget tab

I have been pulling my hair out over this one. I can setup a JQuery Tabs widget and I can put a JQuery TE into each tab.  I can also put a plain old boring TEXTAREA into each tab. Problem is, when I click a tab, I want it to give focus to the text editor instance in the tab. I have tried a variety of ways ot make this work with no luck. 

The code I have been playing with is pasted below. You can see in the javascript function that I have tried several different ways to approach it, all with no luck. This must be doable, maybe someone here knows the trick?

Thanks very much...

  1. <!DOCTYPE html>

  2. <html>
  3. <head>

  4.     <meta charset="UTF-8" />

  5.     <link href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" />
  6.     <script src="http://code.jquery.com/jquery-1.11.3.js"></script>
  7.     <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

  8.     <!-- JQuery TE (HTML editor) -->
  9.     <link href="./jquery-te-1.4.0.css" rel="stylesheet" />
  10.     <script src="./jquery-te-1.4.0.min.js"></script>

  11.     <script>
  12.         $(function() {
  13.             $(".editor").jqte();
  14.         })

  15. $(function()
  16. {
  17. $("#messages").tabs(
  18. {
  19.     activate: function (event, ui) 
  20.     {
  21.     ui.newpanel.setActive();
  22.     ui.newpanel.focus();
  23.    
  24.         //$("#tab_a").focus();
  25.         //$("#tab_a").setActive();
  26.        
  27.     //alert( "You clicked a tab!" );
  28.    
  29.     //var temp = document.getElementById("tab_a");
  30.     //temp.focus();
  31.     //temp.setActive();
  32.     }
  33. })
  34. })

  35.         
  36.     </script>
  37. </head>

  38. <body>

  39.     <FORM>
  40.                 <table id="table_text">
  41.                     <TR>
  42.                         <TD>

  43.                             <div id="messages">
  44.                                 <ul>
  45.                                     <li><a href="#tab_a">Tab A</a></li>
  46.                                     <li><a href="#tab_b">Tab B</a></li>
  47.                                     <li><a href="#tab_c">Tab C</a></li>
  48.                                 </ul>

  49.                                 <div id="tab_a">
  50.                                     <textarea id="tab_a" class="editor" rows="20" cols="72"> </textarea>
  51.                                 </div>

  52.                                 <div id="tab_b">
  53.                                     <textarea id="tab_b" class="editor" rows="20" cols="72"> </textarea>
  54.                                 </div>

  55.                                 <div id="tab_c">
  56.                                     <textarea id="tab_c" class="editor" rows="20" cols="72"> </textarea>
  57.                                 </div>

  58.                             </div>

  59.                         </TD>
  60.                     </TR>
  61.                 </table>
  62.     </FORM>
  63. </body>

  64. </html>