php - HTML editor embedded in admin page -
i'm working on simple webpage company , company wants able edit content time time. have no programing knowledge , therefore want use embedded html editor, have chosen jquery te.
the problem know how use form, e.g.:
<form id = "wyform" method="post" action="test.php"> <textarea class="editor"name = "testtext">hi</textarea> <input type="submit" class="wymupdate" /> </form>
then convert textarea editor jquery:
<script> $('.editor').jqte() </script>
this makes possible send result .php page updates database. many times don't want use textfield or form, simple object convert editor in same way. how save change in case?
catch form submit event , copy content hidden field.
<form id = "wyform" method="post" action="test.php"> <div class="editor" name="testtext">hi</div> <input type="submit" class="wymupdate" /> <input type="hidden" id="editorhiddenfield" /> </form>
...
$('#wyform').submit(function() { $('#editorhiddenfield').val($('.editor').html()); });
you may need use api content instead (i'm not familiar plugin), concept sound.
edit - if don't want use form at all:
<div class="editor></div> <button id="savebutton">save</button>
...
$(document).ready(function() { $('#savebutton').click(function(e) { e.preventdefault(); $.post('savepage.php', { data: $('.editor').html() }).done(function() { alert('saved!'); }); }); });
Comments
Post a Comment