Thank you all. I tried all suggestions but neither of them worked.
I think I'm going to take YUI approach. In YUI they have a function to find elements in DOM based on element name and class. But, all my contents are inside a tab view and loaded using AJAX, so I practically I cannot use onload or onDOMContent ready events. However, in YUI they have some event handler for tabview. I used oncontentchange one, but I have a small problem. When I load the entire page for the first time, the anchor element reacts normally and the function assigned to handle it says "hi". Then when I move to the second tab and click on the anchor element in it, the function works fine, but when I go back to first tab and click on the anchor element, it calls the function like two times. Here is the code that I m usingL
PHP Code:
YAHOO.util.Event.onContentReady("news_tab", init);
function init(e)
{
var rate=YAHOO.util.Dom.getElementsByClassName('btn','a');
YAHOO.util.Event.addListener(rate, "click", hi);
}
function hi(e)
{
alert("hi");
}
PHP Code:
var tab1 = tabView.getTab(1);
tab1.addListener('contentChange', init);
I have tried different combinations, but non of them seems to be working.
Bookmarks