473,804 Members | 3,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding Event to innerHTML

2 New Member
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 4202
Ferris
101 New Member
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
nwaseem
2 New Member
Hey,

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

Thanks
Dec 9 '07 #3

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

Similar topics

6
2825
by: Tim Fooy | last post by:
Hi all, I have the following problem. In my page i have a large <div> with tags inside it that have event handlers on them (onclick etc.). When i run div.innerHTML = moreText + div.innerHTML, either before or after the page has fully loaded, all of those event handlers are dropped: the actions for the event are not executed anymore. I can't find anything related to this problem on the internet. Has anyone ever encountered a similar...
2
6102
by: RobG | last post by:
I have a set of HTML elements that I add an onclick event to at runtime. All it does is get the contents of an element using innerHTML. It all works fine in Firefox, but I can't get it to work in IE. No doubt I have a really simple error.... help! window.event returns an object, but window.event.toElement returns null.
6
5335
by: Tom | last post by:
Hi, In the following code I have reproduced a problem in IE that is extremely annoying for my application. <html> <head> <script type="text/javascript">
19
2350
by: Simon Verona | last post by:
I'm not sure if I'm going down the correct route... I have a class which exposes a number of properties of an object (in this case the object represents a customer). Can I then use this object to databind to text boxes etc? I can't use a dataset as the object has loads of derived logic, for example updating one property may actually update several database fields for example.
3
3991
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having a couple of problems, which I'll try to describe. But this e-mail will only reproduce one of them, in a "short" example. What I'm generally doing is having each form entry contained in a div, which as a label, an input with some event handlers,...
8
2819
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);" TextBox2.Attributes.Add("onKeyPress", jscode) You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as &amp;&amp; in the code that is
6
1830
by: Murray Hopkins | last post by:
Hi. THE QUESTION: How do I get a reference to my Object when processing an event handler bound to an html element ? CONTEXT: Sorry if it is a bit long. I am developing a JS calendar tool. One of the requirements is that the calendar will need to display a varying number of months (1..3)
2
2554
by: charlesjylee | last post by:
I am working with Netscape 7.0 and need to bind a <divwith the innerHTML property. More specifically, I need to bind a GridView in the div in question. I am binding the div with some hardcoded data (a table, which is the HTML equivalent of a GridView). Is there a way with javascript to dump the memory used by a DOM object (the div that I am binding with innerHTML)? When i just receive the variable in javascript, it doesnt seem to leak....
2
2530
by: swethak | last post by:
Hi, i am getting the problem when i used the onclick event in option tag.It is working fine in mozilla .But it is not working IE. Here is my code <script>
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9166
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.