469,626 Members | 1,484 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

Binding Event to innerHTML

Hi everyone,

I'm trying to figure out a way to some how 'bind an event' to the innerHTML property. As an example, if I do something like:

Expand|Select|Wrap|Line Numbers
  1. <containerElement>.innerHTML='some HTML code';
I would like somehow to be able to fire an event to accommodate the updated container content.

I just spent today and yesterday teaching myself prototypes and literals and all that cool stuff; from what I was able to pick up, I came up with the following unfunctioning script:

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript" src="prototype.js"></script>
  2. <script language="javascript" type="text/javascript">
  3.  
  4. Object.prototype.initialize = function(){
  5.   this.innerHTML.bind(this.update());//I'm imagining you laughing at this line :)
  6. }
  7.  
  8. Object.prototype.update = function(){
  9.   alert('testing');
  10. }
  11.  
  12. var vCA;//Will contain an array of containers
  13.  
  14. window.onload = function(){
  15.   document.getElementById('containerDiv').initialize();//Make object into a container
  16. }
  17. </script>
I appreciate your time :)
Dec 9 '07 #1
2 3987
Ferris
101 100+
Hi

innerHTML is a property, not a function ,so it can't be applied with "bind".


by the way,the first parameter of bind is an object,so you should change the line
Expand|Select|Wrap|Line Numbers
  1. this.innerHTML.bind(this.update());//I'm imagining you laughing at this line :)
  2.  
into
Expand|Select|Wrap|Line Numbers
  1. this.innerHTML.bind(this.update);
  2.  

hope it helps.
Dec 9 '07 #2
Hey,

I appreciate your help, I'm probably going to go for an alternate route.

Thanks
Dec 9 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Tim Fooy | last post: by
2 posts views Thread by RobG | last post: by
19 posts views Thread by Simon Verona | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.