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 ?
<script src="https://cloud.tinymce.com/stable/tinymce.min.js?apiKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> jQuery.noConflict(); (function( $ ) { $(function() { tinymce.init({ selector:'textarea', formats : { p : {selector : 'textarea', classes : 'full'}, }, content_style: "body {text-align: justify;}", menubar:true, statusbar: false, }); }); })(jQuery); </script> <textarea id='mce-content-body' name='procedury'></textarea> <table id="procedury" class="table table-striped"> <tbody> <tr><td class="text-center"> <span>kieszenie kostne w okolicy: </span> </td></tr> <tr><td class="text-center"> <span>brak kieszeni kostnych, </span> <span>caries profunda primaria kl., </span> <span>caries profunda secondaria kl., </span> </td></tr> </tbody> </table> <script> var tinymce = $( ".mce-content-body" ); var procedury = document.getElementById('procedury'); // add one event handler to the table procedury.onclick = function (e) { // normalize event e = e || window.event; // find out which element was clicked var el = e.target || e.srcElement; // check if it's a procedury cell if (el.nodeName.toUpperCase() == "SPAN") { // append it's content to the tinymce //tinymce.value += (el.textContent || el.innerText); // tinymce.append(el.textContent); tinyMCE.activeEditor.execCommand('mceInsertContent', false, (el.textContent)); } } </script>
<html> <head> <script src="https://cloud.tinymce.com/stable/tinymce.min.js?apiKey=xxxxxxxxxxxxxxxxxxx"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $.noConflict(); tinymce.init({ selector: '#dokumentacja', content_style: "body {text-align: justify;}", formats : { p : {selector : 'textarea', classes : 'full'}, }, menubar:true, statusbar: false }); </script> <meta charset="UTF-8"> </head> <body> <center> <title>dokumentacja</title> <textarea id="dokumentacja" class='mce-content-body' name='leczenie'></textarea><br/> <br/> <table id="leczenie" class="table table-striped"> <tbody> <tr><td class="text-center"> <SPAN>badanie, </SPAN> <SPAN>przegląd, </SPAN> <SPAN>przegląd, </SPAN> <SPAN>instruktaż, </SPAN> <SPAN>konsultacja, </SPAN> <SPAN>pantomogram, </SPAN> </td></tr> <tr><td class="text-center"> <SPAN>caries media primaria kl., </SPAN> <SPAN>caries media secondaria kl., </SPAN> <SPAN>caries profunda primaria kl., </SPAN> <SPAN>caries profunda secondaria kl., </SPAN> </td></tr> <tr><td class="text-center"> <SPAN>znieczulenie nasiękowe art(1), </SPAN> <SPAN>znieczulenie przewodowe art(1), </SPAN> <SPAN>znieczulenie komputerowe art(1), </SPAN> <SPAN>znieczulenie śródwięzadłowe art(1), </SPAN> </td></tr> <tr><td class="text-center"> <SPAN>skaling, </SPAN> <SPAN>piaskowanie, </SPAN> <SPAN>fluoryzacja, </SPAN> <SPAN>lakowanie, </SPAN> <SPAN>lapisowanie, </SPAN> </td></tr> </tbody> </table> <script> var tinymce = $( ".mce-content-body" ); var leczenie = document.getElementById('leczenie'); // add one event handler to the table procedury.onclick = function (e) { // normalize event e = e || window.event; // find out which element was clicked var el = e.target || e.srcElement; // check if it's a procedury cell if (el.nodeName.toUpperCase() == "SPAN") { // append it's content to the tinymce //tinymce.value += (el.textContent || el.innerText); // tinymce.append(el.textContent); tinyMCE.activeEditor.execCommand('mceInsertContent', false, (el.textContent)); } } </script>
czy mogę prosić kogoś o pomoc z tym skryptem?
Cześć,
nie wiem co Ty tam kombinujesz ale zrobiłem na szybko coś takiego:
https://jsfiddle.net/tx4Lc8a9/342/
kilka tygodni się z tym męczyłem! dzięki wielkie: )
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)