私はこの問題に似た質問を読んできましたが、かなり遠くまで到達することができましたが、明らかに私の状況はわずかに異なりますので、私はまだこれを理解しようとしています。AJAXとJqueryでtinymceエディタを保存する
私はTinymce htmlエディタでスタイル設定されたテキストエリアを持つフォームを持っています。私はAJAXでテキストエリアを自動保存したいと思います。
Iは、時間間隔に基づいて、テキスト領域を節約するコードに取り組んできた。
$(document).ready(function() {
$(function() {
// Here we have the auto_save() function run every 30 secs
// We also pass the argument 'editor_id' which is the ID for the textarea tag
setInterval("auto_save('editor_id')",30000);
});
})。
// Here is the auto_save() function that will be called every 30 secs
function auto_save(editor_id) {
// First we check if any changes have been made to the editor window
if(tinyMCE.getInstanceById(editor_id).isDirty()) {
// If so, then we start the auto-save process
// First we get the content in the editor window and make it URL friendly
var content = tinyMCE.get(editor_id);
var notDirty = tinyMCE.get(editor_id);
content = escape(content.getContent());
content = content.replace("+", "%2B");
content = content.replace("/", "%2F");
// We then start our jQuery AJAX function
$.ajax({
url: "PAFormAJAX.asp", // the path/name that will process our request
type: "POST",
data: "itemValue=" + content,
success: function(msg) {
alert(msg);
// Here we reset the editor's changed (dirty) status
// This prevents the editor from performing another auto-save
// until more changes are made
notDirty.isNotDirty = true;
}
});
// If nothing has changed, don't do anything
} else {
return false;
}
}
これ取り組んでいるが、私はいつも私が使用できる静的editor_id年代を持っていないので、私の問題は、フォーム要素を動的に作成されています。どのように動的IDを受け入れるように更新できますか?
例えば、ここでは、動的にASPで設定されていることのidを持つテキストエリアの一つだ:
<textarea id="Com<%=QuesID%>" row= "1" cols= "120" name="Com<%=QuesID%>" QuesID="<%=QuesID%>" wrap tabindex="21" rows="10" class="formTxt"><%=TempTxt%></textarea>
また、私は時間間隔に保存機能をだけでなく、を呼び出す方法を把握しようとしていますユーザーがテキストエリアをクリックしてフォーカスを失うと、私はTinyMceがテキストエリアからiframeにそれを変えるので、これをどうやって行うのか分かりません。
ご協力いただきまして誠にありがとうございます。
はまた、私は私のオリジナルのポストでこの質問を含むことを意味します。私の保存機能でtextareaタグに入れた属性を参照する方法はありますか?私が与えたテキストエリアの例では、エディタで保存が呼び出されたときにQuesIDを取得したいと考えています。私はどのようにこれを呼び出すか分からない。 – Cineno28