I'm not dead...yet.

how to store javascript object in html object?

I need to call an object method when a div is clicked...

any idea of how to store the javascript object in the html element?
Permalink Rob IXI 
April 12th, 2007 1:17am
Use a Hash to store the functions, with the keys being the ids. You then use the same id in the div and in the Hash to lookup the required method.

<div id="unique_987">...</div>

var MyHash = {};

MyHash["unique_987"] = function(){

Then hook from the on click event. You probably can choose among some variations of this idea. Basically, it's a good idea to keep the HTML elements as pure as possible, see:
Permalink alert 
April 12th, 2007 2:30am
alert, I found a solution that looks like that...

function f(obj,elementID)
div1 = ...
var x = document.getElementById(elementID);


div1 is an element. the element gets the javascript object by the function.

later in javascript...

var x = new object();

what do you think of this solution?
Permalink Rob IXI 
April 12th, 2007 2:51am
Seems like this will be an slow day...
Permalink Send private email Masiosare 
April 12th, 2007 1:25pm

This topic is archived. No further replies will be accepted.

Other topics: April, 2007 Other topics: April, 2007 Recent topics Recent topics