Is it possible to have one jQuery ready block executed after all others have done so.
I have this in my master page ...
How about only you only registring one document.ready() on the master page, and then let that one execute the code based on a variable? This solution is not that elegant, but a search for JavaScript thread synchronization didn't really turn op anything.
You could change the code on the master page to:
<script type="text/javascript">
var runWysiwyg = false;
$(document).ready(function()
{
if (runWysiwyg) {
$('textarea.message-body').wysiwyg();
}
$("input[type='text']:enabled:first", document.forms[0]).focus().select();
});
</script>
And put this script in you page:
<script type="text/javascript">
runWysiwyg = true;
</script>
Add a custom event trigger to your master page:
<script type="text/javascript">
$(document).ready(function()
{
$('textarea.message-body').wysiwyg();
$(document).trigger('tb');
});
</script>
And bind it to the other page:
<script type="text/javascript">
$(document).bind('tb', function(){
$("input[type='text']:enabled:first", document.forms[0]).focus().select();
});
</script>
References
jQuery Special Events...Virtually, not in Real Life
How to Create Custom Events in JavaScript
AOP Aspect of JavaScript
$(window).load()
function fires after the $(document).ready()
This is the solution I went with.
In my master page I have this...
<script type="text/javascript">
<!--
$(document).ready(function()
{
if (typeof (OnLoad) != "undefined")
{
OnLoad();
}
$("input[type='text']:enabled:first", document.forms[0]).focus().select();
});
//-->
</script>
and in my detail pages I have this...
<script type="text/javascript">
<!--
function OnLoad()
{
$('textarea.message-body').wysiwyg();
}
//-->
</script>