How to make sure that the DOM tree output by writeCapture's captive script has loaded?

40 views
Skip to first unread message

pulkitsinghal

unread,
Nov 14, 2011, 6:04:15 PM11/14/11
to writeCapture.js Users
Hello,

Does the data loaded by a captured script's document.write() get
loaded into the DOM tree before the next statement executes? If not,
then can we provide write capture with some kind of callback that will
be used after it has finished loading the 3rd party script? (so that
the generated DOM may be manipulated)

I have the following in of my blogger posts:

1) Get jQuery
<script
src="http://code.jquery.com/jquery-1.6.4.min.js"
type="text/javascript"
charset="utf-8">
</script>

2) Get the write capture js
<script
src="http://raw.github.com/iamnoah/writeCapture/master/
writeCapture.js"
type="text/javascript"
charset="utf-8">
</script>

3) Get the js for making write capture serve as a jQuery plugin
<script
src="http://raw.github.com/iamnoah/writeCapture/master/plugin/
jquery.writeCapture.js"
type="text/javascript"
charset="utf-8">
</script>

4) Inject the output of a Gist script into a placeholder and change
the background color of line 3 (id=LC3) but this color doesn't take
effect :(
<script type="text/javascript">
$(document).ready(
function() {
$('#foo').writeCapture().html(
'<scrip'+'t src="https://gist.github.com/1243028.js"> </
s'+'cript>'
);
$('#LC3', '#foo').css({'background-color': 'green', 'color':
'green'});
});
</script>

pulkitsinghal

unread,
Nov 14, 2011, 6:22:09 PM11/14/11
to writeCapture.js Users
Ok the docs ok the wiki are either really inconsistent or I'm just
reading them wrong but with hints fro mthe wiki and trial & error I
got this working:
<script type="text/javascript">
$(document).ready(
function() {
var $captured = $('#foo');
$captured.writeCapture().html(
'<scrip'+'t src="https://gist.github.com/1243028.js"> </
s'+'cript>',
function() {
$('#LC3', $captured).css({'background-color': 'green',
'color': 'green'});
}
);
});
</script>

pulkitsinghal

unread,
Nov 14, 2011, 6:47:57 PM11/14/11
to writeCapture.js Users
Thanks for the great product, I was finally able to finish my blog
entry:
http://pulkitsinghal.blogspot.com/2011/11/ideas-for-improving-githubs-gist.html

I would like to say that the wiki could definitely be much better.
I've kicked things off by editing it based on what I learned by trial
& error.

Cheers,
- Pulkit

noah

unread,
Nov 14, 2011, 6:52:14 PM11/14/11
to writecaptu...@googlegroups.com
Hi ,

With the plugin, the last parameter is always a callback:
https://github.com/iamnoah/writeCapture/tree/master/plugin

Feel free to open a pull request if you have improvements to the docs.

Cheers,
Noah

Reply all
Reply to author
Forward
0 new messages