JS Question: How to include a parameter when assigning a function to an event.

2009-06-18 Thread Ian Skinner
I have this code that is assigning a JS function to the onClick events of elements. container.childNodes[i].onclick = openClose; I would like to assign parameters so that the openClose function of different elements function on specific items. I recoginize that this syntax is not going to

Re: JS Question: How to include a parameter when assigning a function to an event.

2009-06-18 Thread Ian Skinner
I finally found the right combination of Google Search terms and following other links to find at least one solution: container.childNodes[i].onclick = function() {openClose('hello world')}; I would be interesting in hearing if there are other solutions or any difficulties I might have with

Re: JS Question: How to include a parameter when assigning a function to an event.

2009-06-18 Thread cold.fusion
Other solutions? Use JQuery or Ext Core for this type of binding. Makes it very simple, and avoids any cross browser issues. Steve Cutter Blades Adobe Certified Professional Advanced Macromedia ColdFusion MX 7 Developer Co-Author of Learning Ext JS http://www.packtpub.com/learning-ext-js/book

Re: JS Question: How to include a parameter when assigning a function to an event.

2009-06-18 Thread Tony Bentley
Use JQuery and then check out the documentation on binding an event. A classic example is passing the id to a function to identify that element inside of the function: $(#TheButton).bind(click,function(el){openClose( $(this).attr(id) )}); function openClose(el){ if($(el).is(.closed)){