﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
8637	CKeditor isn't picked up by jQuery :input	fooquency		"I wish to add the 'Are you sure you want to leave this page' dialog to avoid page editors losing material accidentally.

jQuery provides a useful :input selector, which means that a change to any form input/textarea/select/button widget can be used to trigger the dialog using:

{{{
function removeCheck() { window.onbeforeunload = null; }
$(document).ready(function() {
    $(':input').one('change', function() {
	window.onbeforeunload = function() {
            return 'Leaving this page will cause edits to be lost. Press the submit button on the page if you wish to save your data.';
        }
    });
    $('input[type=submit]').click(function() { removeCheck() });
});
}}}

This certainly works for normal textareas.

However, when CKeditor is added, this doesn't then get picked up:

{{{
<html>
<head>
	<title>richtext</title>
	<script type=""text/javascript"" src=""http://ckeditor.com/apps/ckeditor/3.6.2/ckeditor.js?1325679318""></script>
	
	
	<script type=""text/javascript"" src=""http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js""></script>
	<script type=""text/javascript"">
				function removeCheck() { window.onbeforeunload = null; }
				$(document).ready(function() {
				    $(':input').one('change', function() {
						window.onbeforeunload = function() {
				            return 'Leaving this page will cause edits to be lost. Press the submit button on the page if you wish to save your data.';
				        }
				    });
				    $('input[type=submit]').click(function() { removeCheck() });
				});
	</script>

	
</head>
<body>
	<!-- http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Integration -->
	<form method=""post"">
		<p>
			Editor:<br />
			<textarea id=""editor1"" name=""editor1"">&lt;p&gt;Initial value.&lt;/p&gt;</textarea>
			<script type=""text/javascript"">
				CKEDITOR.replace( 'editor1' );
			</script>
			
			<textarea name=""normaltextarea"">Normal textarea</textarea>
		</p>
		<p>
			<input type=""submit"" />
		</p>
		<p><a href=""http://www.google.com/"">Link elsewhere</a></p>
	</form>


</body>
</html>
}}}

Obviously I can't be sure if this is a CKeditor bug or a jQuery bug, or is by design on either side.
"	Bug	closed	Normal		General	3.6.2	invalid		
