Tratando de conseguir el texto escrito dentro de un TinyMCE textarea
Estoy tratando de conseguir el texto escrito dentro de un TinyMCE textarea
. Tengo el código a continuación. Se muestra el área de texto TinyMCE, pero la alerta ni siquiera se muestra. ¿Por qué?
<html>
<head></head>
<body>
<script type="text/javascript" src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js'></script>
<script type="text/javascript" src="/home/javiergarcia/Scaricati/jari/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
});
$(document).ready(function() {
$('form').submit(function() {
//alert("fasdfs");
alert(tinyMCE.get('#jander').getContent());
});
});
</script>
<form method="post" action="somepage">
<textarea name="content" id="jander" style="width:100%"></textarea>
<input type="submit">
</form>
</body>
</html>
Saludos
Javier
5 answers
¿Por qué no simplemente usas tinymce.get('jander').getContent();
(tinymce en minúsculas!) ?
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-03-25 10:13:47
Simplemente debe solicitar el valor del control textarea original.
tinyMCE.triggerSave(false, true);
$('#jander').val();
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-03-25 09:51:39
Una vez que haya incluido el complemento TinyMCE jQuery, asigne el editor a una variable y luego puede operar cualquier función jQuery en ella:
var wysiwyg = $('textarea.tinymce').tinymce(tinymce_settings);
Luego, para obtener el contenido, solo tiene que buscar wysiwyg.html();
También, vea la documentación de jQuery de TinyMCE para otras técnicas de manipulación.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-03-25 10:09:09
Como alguien me dijo, el carácter agudo (#) se usa en los selectores jQuery y no tiene nada que ver con TinyMCE.conseguir(). Así que con esta línea a continuación funciona bien.
alert(tinyMCE.get('jander').getContent());
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-03-25 10:34:54
Prueba este....
$.trim (tinymce.get ('jander').getContent());
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-03-14 11:08:55