Welcome Guest, Not a member yet? Register   Sign In
jConfirm and unload event
#1

[eluser]SPeed_FANat1c[/eluser]
Hi,

I have a textarea with TINYMCE editor. When user leaves page but don't save data, I want to show confirmation message. Standart javascript confirm message works fine, but when I use jConfirm, it does not show the question.

This jquery plugin is from this site: http://abeautifulsite.net/blog/2008/12/j...t-dialogs/

My code:

Code:
<scrip type="text/javascript" src="&lt;?php echo base_url()?&gt;js/tiny_mce/tiny_mce.js"></scrip>
<scrip  src="&lt;?php echo base_url()?&gt;js/jqueryAlerts/jquery.alerts.js" type="text/javascript"></scrip>

<scrip type="text/javascript">

var _isDirty = false;

function unsaved()
{
  
    
    jConfirm('Jūs neišsaugojote duomenų. Ar tikrai norite išeiti?', 'Patvirtinimas', function(r){
        if(r)
        {
            alert('test');
            
        }
    });
    //
}

$(document).ready(function(){
  
    $('.prisijungta').remove();
    
  
    
    
    
    $(window).unload(function() {
        if(_isDirty){
            
            
            unsaved();

//            jAlert('dirty');
//            alert('dirty');
        };
    });

    
});

function change(inst) {
    _isDirty = true;
}

tinyMCE.init({
    theme : "advanced",
    mode : "textareas",
    plugins : "fullpage",
    theme_advanced_toolbar_location : "top",
    //theme_advanced_buttons3_add : "fullpage"
    theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
    onchange_callback : "change"
});
</scrip>

Have you any idea why this does not work?

BTW when I put it out of unsaved() function, the plugin works. it only does not work in unsaved() function.
#2

[eluser]Christophe28[/eluser]
Do you have a testpage so we can have a look?
#3

[eluser]SPeed_FANat1c[/eluser]
I googled about this stuff and it seem that it is not possible use custom dialog becauase of security reasons. And yet I found the simple way to solve this problem, although not in such way I wanted but at least users gets question - simply add plugins : "autosave" to tinyMCE.init.

http://wiki.moxiecode.com/index.php/Tiny...s/autosave




Theme © iAndrew 2016 - Forum software by © MyBB