On 30-May-06, at 11:12 AM, ManDude wrote:
> Beau, I tried that, but (I'm very new to MochiKit) I don't think I
> quite got the syntax right
>
> Here's a more complete example (with my attempt at implementing the
> connect() from above. I've left in my previous attempts commented
> out:
>
> I call StickItIn when the doSimpleXMLHttpRequest is called back:
> returntext is the reponseText
>
> function StickItIn(putwhere, returntext) {
> ret = returntext.split("<break>");
>
> var code = ret[1];
> var pretext = ret[2];
> var imgsrc = ret[3];
> var imgmap = ret[4];
> var extratext = ret[5];
> var imgtag = ret[6];
>
> var target = document.getElementById(putwhere);
>
> // First remove whatever's there
> while (target.hasChildNodes()) {
> target.removeChild(target.firstChild);
> }
>
> if (code == "IMAGE") {
> // Preload image
> /*
> preload = new Image();
> preload.src = imgsrc;
> preload.onload = reallydo(tpretext, img, textra);
> */
>
> // Load Pretext
> var tpretext = document.createElement('span');
> tpretext.innerHTML = pretext;
>
> // Load Image
> var img = document.createElement('img');
> img.setAttribute("src",imgsrc);
> img.setAttribute("USEMAP",imgmap);
> img.setAttribute("border","0");
>
> // Load Posttext
> var textra = document.createElement('span');
> textra.innerHTML = extratext;
>
> // Preload image
> SetStatus("before preload");
> preload = new Image();
> preload.src = imgsrc;
> someobj = "Hello";
> connect(preload, 'onload', img, function (data) {
> target.appendChild(tpretext);
> target.appendChild(img);
> target.appendChild(textra);
> });
>
> // This is how I did it first
> //target.appendChild(tpretext);
> //target.appendChild(img);
> //target.appendChild(textra);
> }
> return 1;
> }
Try reducing this further. Have you tried defining the width/height
of the image? Have you tried doing this 100% with innerHTML? Have you
tried setting some div's style's background instead of loading an image?
At this point, you're probably just working around browser quirks.
You'll need to do experiments one line at a time.
BTW, I don't think your connect doesn't needs img as a parameter:
connect(preload, 'onload', function (data) {
Good luck!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---