PDA

View Full Version : jQuery POST tinyeditor



ggalan
10-22-2011, 12:35 AM
i have this which works well but want to change it to a jQuery version


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="style.css" />
<script src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="tinyeditor.js"></script>
</head>
<body>
<form id="bodyText" method="POST" action="confirmText.php">
<textarea id="descText" name="input" style="width:400px; height:200px"></textarea>
<input class="bodyTextBtn" type="submit" value="confirm text" onclick='my_instance.post()'/>
</form>
<script type="text/javascript">
var my_instance = new TINY.editor.edit('editor',{
id:'descText',
width:730,
height:400,
cssclass:'te',
controlclass:'tecontrol',
rowclass:'teheader',
dividerclass:'tedivider',
controls:['bold','italic','underline','strikethrough'],
footer:true,
fonts:['Verdana','Arial','Georgia','Trebuchet MS'],
xhtml:true,
cssfile:'style.css',
bodyid:'editor',
footerclass:'tefooter',
toggle:{text:'source',activetext:'wysiwyg',cssclass:'toggle'},
resize:{cssclass:'resize'}
});
</script>
</body>
</html>

so i would have to change those areas in highlight to


<form id="bodyText" method="POST" action="">

<input class="bodyTextBtn" type="submit" value="confirm text"/>

and my jQuery code which doesnt work at the moment


$("#bodyText").submit(function() {
var $form = $(this),
dText = $form.find( 'body[id="editor"]' ).val();
$.post( 'confirmText.php?', {descText:dText}, function( data ) {
//call back
});
return false;
});

confirmText.php


<?
$bar = $_POST['input'];
?>

ggalan
10-22-2011, 03:41 AM
getting closer, this is outputting. atleast its something

[object Object]1



<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TinyEditor - JavaScript WYSIWYG Editor</title>
<link rel="stylesheet" href="style.css" />
<script src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="tinyeditor.js"></script>
</head>
<body>
<form id="bodyText" method="POST">
<textarea id="descText" name="descText" style="width:400px; height:200px"></textarea>
<input class="bodyTextBtn" type="submit" value="confirm text"/>
</form>
<script type="text/javascript">

function h(){

var my_instance = new TINY.editor.edit('editor',{
id:'descText',
width:730,
height:400,
cssclass:'te',
controlclass:'tecontrol',
rowclass:'teheader',
dividerclass:'tedivider',
controls:['bold','italic','underline','strikethrough'],
footer:true,
fonts:['Verdana','Arial','Georgia','Trebuchet MS'],
xhtml:true,
cssfile:'style.css',
bodyid:'editor',
footerclass:'tefooter',
toggle:{text:'source',activetext:'wysiwyg',cssclass:'toggle'},
resize:{cssclass:'resize'}
});

$(document).ready(function(){
$("#bodyText").submit(function() {
var m = my_instance + "1";
$.post( 'confirmText.php?',{descText:m}, function() {
// callback
});
return false;
});
});
</script>
</body>
</html>