JR Utily

- JS script to manage include of tinymce lib just once

...@@ -19,15 +19,35 @@ ...@@ -19,15 +19,35 @@
19 19
20 <!-- content --> 20 <!-- content -->
21 <!-- <ui:define name="content">--> 21 <!-- <ui:define name="content">-->
22 -<head> 22 +<head jsf:id="head">
23 - <script type="text/javascript" src="resources/tinymce/tinymce.js"></script> 23 +
24 - <script type="text/javascript"> 24 + <script jsf:id="tinymce" jsf:target="head" type="text/javascript">
25 +
26 + // Adding the script tag to the head as suggested before
27 + var head = document.getElementsByTagName('head')[0];
28 + var script = document.createElement('script');
29 + script.type = 'text/javascript';
30 + script.src = 'resources/tinymce/tinymce.js';
31 +
32 + var callback = function(){
25 tinymce.init({ 33 tinymce.init({
26 selector: 'textarea.mytinymce' 34 selector: 'textarea.mytinymce'
27 }); 35 });
36 + };
37 +
38 + // Then bind the event to the callback function.
39 + // There are several events for cross browser compatibility.
40 + script.onreadystatechange = callback;
41 + script.onload = callback;
42 +
43 + // Fire the loading
44 + head.appendChild(script);
45 +
28 </script> 46 </script>
47 +
29 </head> 48 </head>
30 -<body> 49 +<body jsf:id="body">
50 +
31 51
32 52
33 <h2><h:outputText value="Cration " rendered="#{empty(updateUserBean.userId)}"/> 53 <h2><h:outputText value="Cration " rendered="#{empty(updateUserBean.userId)}"/>
......