Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-23-2009, 04:18 AM   PM User | #1
Sleeping_Troll
New Coder

 
Join Date: May 2009
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Sleeping_Troll is an unknown quantity at this point
After DOM insertion element is "null"

Here is my script:
Code:
$('userPanel').observe('DOMNodeInserted', function(){
  $("EditImage").src="../images/main/Qmark.png";
  $("controlsUpload").innerHTML="<form id='UploadData' name = 'UploadData' action='php/uploader.php' method='post' enctype='multipart/form-data' target='upload_target' ><div ><input id='UploadFile' name='UploadFile' type='file' size=24 onChange = 'StartUpload()'/></div></form>"
});
The DOMNodeInserted event is defined as firing after the insertion, $('EditImage') is an element that was inserted into $('userPanel') however in the reference to it that follows firefox reports "$('EditImage') is null" What's up?
I was thinking it was a matter of timing but javascript is single threaded and I don't see how that can be... or does my browser have something to do with that, but no, because the event does not fire until the DOM insertion is complete... My brain wants to leap out of my skull and run screaming through the streets!
Sleeping_Troll is offline   Reply With Quote
Old 06-23-2009, 02:51 PM   PM User | #2
ohgod
Regular Coder

 
ohgod's Avatar
 
Join Date: Jun 2008
Location: Ohio
Posts: 579
Thanks: 6
Thanked 69 Times in 69 Posts
ohgod is on a distinguished road
"DOMNodeInserted
Fired when a node has been added as a child of another node. This event is dispatched after the insertion has taken place. The target of this event is the node being inserted.
Bubbles: Yes
Cancelable: No
Context Info: relatedNode holds the parent node
"

so in theory you ought to be able to include the event in your function and fiddle with that.

Code:
$('userPanel').observe('DOMNodeInserted', function(event){
var el = event.element(); 
  el.writeAttribute('src',"../images/main/Qmark.png";
  $("controlsUpload").innerHTML="<form id='UploadData' name = 'UploadData' action='php/uploader.php' method='post' enctype='multipart/form-data' target='upload_target' ><div ><input id='UploadFile' name='UploadFile' type='file' size=24 onChange = 'StartUpload()'/></div></form>"
});
ohgod is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:44 AM.


Advertisement
Log in to turn off these ads.