Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] wstawianie tekstu do textarea z tinymce
dentopolis
post 9.03.2018, 23:21:33
Post #1





Grupa: Zarejestrowani
Postów: 252
Pomógł: 0
Dołączył: 14.08.2016

Ostrzeżenie: (0%)
-----


witam, jakiś czas temu szukałem rozwiązania jak wstawić tekst ujęty <span>jakiś tekst</span> jednym kliknięciem do textarea. w tym wątku http://forum.php.pl/lofiversion/index.php/t257740.html udało mi się to uzyskać ale straciłem ten kod. czy ktoś może mi wskazać co konkretnie powinienem zmienić w kodzie ?

  1. <script src="https://cloud.tinymce.com/stable/tinymce.min.js?apiKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"></script>
  2. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  3. <script>
  4. jQuery.noConflict();
  5. (function( $ ) {
  6. $(function() {
  7. tinymce.init({
  8. selector:'textarea',
  9. formats : {
  10. p : {selector : 'textarea', classes : 'full'},
  11. },
  12. content_style: "body {text-align: justify;}",
  13. menubar:true,
  14. statusbar: false,
  15.  
  16. });
  17. });
  18. })(jQuery);
  19.  
  20.  
  21. </script>
  22.  
  23. <textarea id='mce-content-body' name='procedury'></textarea>
  24.  
  25.  
  26.  
  27.  
  28. <table id="procedury" class="table table-striped">
  29. <tbody>
  30. <tr><td class="text-center">
  31. <span>kieszenie kostne w okolicy: </span>
  32. </td></tr>
  33.  
  34. <tr><td class="text-center">
  35. <span>brak kieszeni kostnych, </span>
  36. <span>caries profunda primaria kl., </span>
  37. <span>caries profunda secondaria kl., </span>
  38. </td></tr>
  39. </tbody>
  40. </table>
  41.  
  42. <script>
  43. var tinymce = $( ".mce-content-body" );
  44. var procedury = document.getElementById('procedury');
  45. // add one event handler to the table
  46. procedury.onclick = function (e) {
  47. // normalize event
  48. e = e || window.event;
  49. // find out which element was clicked
  50. var el = e.target || e.srcElement;
  51. // check if it's a procedury cell
  52. if (el.nodeName.toUpperCase() == "SPAN") {
  53. // append it's content to the tinymce
  54. //tinymce.value += (el.textContent || el.innerText);
  55. // tinymce.append(el.textContent);
  56. tinyMCE.activeEditor.execCommand('mceInsertContent', false, (el.textContent));
  57. }
  58. }
  59. </script>


czy ktoś ma pomysł jak to rozwiązać?

obecny stan: http://dentopolis.org/dokumentacja.php

teraz wyświetla mi się textarea w tinymce ale nadal klikanie bez akcji. dodałem jquery noconflict.

  1. <html>
  2. <head>
  3.  
  4.  
  5.  
  6. <script src="https://cloud.tinymce.com/stable/tinymce.min.js?apiKey=xxxxxxxxxxxxxxxxxxx"></script>
  7. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  8.  
  9.  
  10.  
  11.  
  12. <script>
  13. $.noConflict();
  14. tinymce.init({
  15. selector: '#dokumentacja',
  16. content_style: "body {text-align: justify;}",
  17. formats : {
  18. p : {selector : 'textarea', classes : 'full'},
  19. },
  20. menubar:true,
  21. statusbar: false
  22. });
  23. </script>
  24.  
  25. <meta charset="UTF-8">
  26.  
  27. </head>
  28.  
  29. <body>
  30.  
  31. <center>
  32.  
  33. <title>dokumentacja</title>
  34.  
  35.  
  36. <textarea id="dokumentacja" class='mce-content-body' name='leczenie'></textarea><br/>
  37. <br/>
  38. <table id="leczenie" class="table table-striped">
  39. <tbody>
  40. <tr><td class="text-center">
  41. <SPAN>badanie, </SPAN>
  42. <SPAN>przegląd, </SPAN>
  43. <SPAN>przegląd, </SPAN>
  44. <SPAN>instruktaż, </SPAN>
  45. <SPAN>konsultacja, </SPAN>
  46. <SPAN>pantomogram, </SPAN>
  47. </td></tr>
  48.  
  49. <tr><td class="text-center">
  50. <SPAN>caries media primaria kl., </SPAN>
  51. <SPAN>caries media secondaria kl., </SPAN>
  52. <SPAN>caries profunda primaria kl., </SPAN>
  53. <SPAN>caries profunda secondaria kl., </SPAN>
  54. </td></tr>
  55.  
  56. <tr><td class="text-center">
  57. <SPAN>znieczulenie nasiękowe art(1), </SPAN>
  58. <SPAN>znieczulenie przewodowe art(1), </SPAN>
  59. <SPAN>znieczulenie komputerowe art(1), </SPAN>
  60. <SPAN>znieczulenie śródwięzadłowe art(1), </SPAN>
  61. </td></tr>
  62.  
  63.  
  64.  
  65. <tr><td class="text-center">
  66. <SPAN>skaling, </SPAN>
  67. <SPAN>piaskowanie, </SPAN>
  68. <SPAN>fluoryzacja, </SPAN>
  69. <SPAN>lakowanie, </SPAN>
  70. <SPAN>lapisowanie, </SPAN>
  71. </td></tr>
  72.  
  73. </tbody>
  74. </table>
  75.  
  76.  
  77. <script>
  78. var tinymce = $( ".mce-content-body" );
  79. var leczenie = document.getElementById('leczenie');
  80. // add one event handler to the table
  81. procedury.onclick = function (e) {
  82. // normalize event
  83. e = e || window.event;
  84. // find out which element was clicked
  85. var el = e.target || e.srcElement;
  86. // check if it's a procedury cell
  87. if (el.nodeName.toUpperCase() == "SPAN") {
  88. // append it's content to the tinymce
  89. //tinymce.value += (el.textContent || el.innerText);
  90. // tinymce.append(el.textContent);
  91. tinyMCE.activeEditor.execCommand('mceInsertContent', false, (el.textContent));
  92. }
  93. }
  94. </script>


Ten post edytował dentopolis 9.03.2018, 23:22:04
Go to the top of the page
+Quote Post
dentopolis
post 12.03.2018, 21:33:28
Post #2





Grupa: Zarejestrowani
Postów: 252
Pomógł: 0
Dołączył: 14.08.2016

Ostrzeżenie: (0%)
-----


czy mogę prosić kogoś o pomoc z tym skryptem?
Go to the top of the page
+Quote Post
aras785
post 12.03.2018, 23:01:28
Post #3





Grupa: Zarejestrowani
Postów: 859
Pomógł: 177
Dołączył: 29.10.2009

Ostrzeżenie: (0%)
-----


Cześć,

nie wiem co Ty tam kombinujesz ale zrobiłem na szybko coś takiego:

https://jsfiddle.net/tx4Lc8a9/342/

Ten post edytował aras785 12.03.2018, 23:06:14
Go to the top of the page
+Quote Post
dentopolis
post 12.03.2018, 23:10:20
Post #4





Grupa: Zarejestrowani
Postów: 252
Pomógł: 0
Dołączył: 14.08.2016

Ostrzeżenie: (0%)
-----


kilka tygodni się z tym męczyłem! dzięki wielkie: )
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 29.03.2024 - 16:19