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
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
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
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)){
4 matches
Mail list logo