Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7567551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:41:32+00:00 2026-05-30T14:41:32+00:00

I am using tinymce editor to provide rich text formatting and along with that

  • 0

I am using tinymce editor to provide rich text formatting and along with that I want to provide the option of autosave. I managed to write a script that does exactly that, but there is one problem. I do not want to call that save function if the window is not the current tab, so that unnecessary save calls are not made.

To over come this I using the $(window).focus() but this does not seem to work because when the tinyMCE editor is in focus (meaning I am typing in it) somehow the window goes out of focus (most probably because tinyMCE editor uses an iFrame) and as a result my periodic update function is not being called.

i would very easily solved this problem if there was a handler .onFocus for the editor but there seems to be none. Can anybody suggest me how can I overcome this problem? My code is given below

/* Function to be called for saving the blog */
function saveBlog(){

    var ed = tinymce.activeEditor;
    /* Ajax call will be done only when some changes has been made in the editor*/
    if (ed.isDirty())
    {
        ed.save();
        var link = $(this).attr("href");
        var cur_elem = $(this);
        cur_elem.html('saving...');
        cur_elem.addClass('unclickable');

        $.ajax({
            type: "POST",
            url: link,
            data: $("#blog_form :input[name!='csrfmiddlewaretoken']").serialize(),
            dataType: 'json',
             success: function(){
                cur_elem.html('Save');
                cur_elem.removeClass('unclickable');
            }
        });
    }

};


var interval_id;

/* Timer resumes when the window comes back in focus */
$(window).focus(function() {
    if (!interval_id)
        interval_id = setInterval(saveBlog, 5000);
});

/* Whenever window goes out of focus the timer is cleared */
$(window).blur(function() {
    clearInterval(interval_id);
        interval_id = 0;
});

/* Starts the auto saving for the first time */
$(document).ready(function(){
     interval_id = setInterval(saveBlog, 5000);
});

Can anybody help with this problem, I just need to know when the tinyMCE editor instance is in focus so that I can resume the auto saving periodic function. I can add that in addition to the $(window).focus

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:41:33+00:00Added an answer on May 30, 2026 at 2:41 pm

    Did you try the onActivate-handler already?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using TinyMCE to provide rich text formatting options and I want to
I am using TinyMCE to provide a rich text editing text editor. But the
I'm using TinyMCE to provide users the capability of simple text formatting (bold, italics,
i m using tinymce editor on joomla component that behave strangly tinymce is already
I am using asp.net, i have added tinyMCE editor to my page. I want
I'm using TINYMCE text editor and if you use a double space the string
I am using TinyMCE editor. I want to clear the content inside the editor
I am trying to select a specified text in TinyMCE editor using JavaScript in
im using tinymce for my text editor, i wanted a code highlighting feature for
I have a website that allows to enter HTML through a TinyMCE rich editor

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.