Yii 1.1: asktosavework

Ask to user if he want to exit before save his work using onbeforeunload event
9 followers

This simple extension ask to user if he want to exit before save his work using onbeforeunload event. It's the same behavior as Facebook when you are editing your status.

The extension disable the message only when you submit a form with submit type button, otherwise it shows the message.

You can optionally use an input element (ex. #Page_title, .Page_description) to watch. This way we can know if user is actually editing or not (avoiding unnecesary messages)

Requirements

jQuery (1.x) Yii 1.1 or above Tested in (IE9, Chrome and Firefox), not tested in IE8 or IE7

Usage

Save the file "AskToSaveWork" in /protected/extensions and just put the widget in any _form, wherever you want:

<?php $this->widget('ext.AskToSaveWork', array('watchElement'=>'#Product_name','message'=>Yii::t('messages', "You haven't save your product yet!")))?>

Resources

Total 1 comment

#19853 report it
Hipogea at 2016/05/10 03:17am
doesn' twork

I know what did wrong ; but doesn't work

Leave a comment

Please to leave your comment.

Create extension