I needed to do some magical AJAXy previewing (inline) for an email templating system I’m building that generates both text and HTML versions of an email. For displaying the HTML version of the email inline I was using an iFrame. Using jQuery to do an AJAX post of the template, I then needed to render the response inline, and essentially wanted to just replace the HTML contents of an iFrame with the HTML response I received back from my AJAX jQuery post.
I found this tidbit from Twig’s Tech Tips, which did exactly what I wanted. Using an iFrame like this (no src attribute):
<iframe id="preview-iframe" width="320" height="240"></iframe>
You can use this jQuery call to replace the contents of the iFrame:
$('#preview-iframe').contents().find('html').html(data);
I couldn’t get a jQuery datepicker to bind to an element that was being displayed in a colorbox (even when trying with jQuery Live). Found a solution on (surprise) StackOverflow.
Here is a handy web tool for checking the validity of JSON. I’ve been generating a lot of funny custom JSON lately, and every now and again I get it wrong.
When jQuery gets ahold of invalid JSON data on a $.getJSON call, it fails silently, which can leave you with a head-scratcher, until you fix your broken JSON data.
Yes. It’s 1:26 am, and I’m working on stuff. Really, I’d like to be in bed. Asleep. And I’d like to stay there for three days.
But alas, instead, if you are having problems with dropdown JavaScript menus appearing BEHIND a Flash object, try adding this to the parameters you’re passing to the Flash object:
wmode="transparent"
Or if you’re using SWFObject, you can do something like this instead:
var so = new SWFObject("crappy.swf", "crappy_swf", "100%", "100%", "9", "#ffffff");
so.addParam("wmode", "transparent");
so.write("flash");
Maybe that will save you some headaches. It saved me some.
UPDATE
Apparently it might be better to use
wmode="opaque"
Apparently it’s less CPU intensive, and it seems to do the same job (that’s how it worked for me, anyway). I believe the differences are as follows:
Opaque makes Flash behave like any other page element, allowing you to easily float content over it using JavaScript and DHTML.
Transparent makes the page background underneath the Flash video appear through any transparent areas of the Flash video.