CodeIgniter Forums

Full Version: jConfirm and unload event
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum


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:

My 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){

    $(window).unload(function() {

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


function change(inst) {
    _isDirty = true;

    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"

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.

El Forum

Do you have a testpage so we can have a look?

El Forum

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.