Alert Displayed Twice, For Only One Ajax Call?

Solved! The problem was, that I had two different button columns, generated with the same code (only parametrised) and, since Yii reffers to such buttons via class, not id (obvious), thus I’ve ended up with two event handlers.

[s]After spending last two hours on trying to solve this problem myself, after reading many articles, blog posts and forum threads on Yii forum, StackOverflow and in many other sources, I failed and must ask for help.

I have CButtonColumn with two buttons, each defined the same way:


[size=“2”]The idea is “borrowed” from default CButtonColumn’s delete button (and from [/size]this article[size=“2”]). The only difference is, that the message is displayed after AJAX call and only in case of error (if there is no error, server returns empty string and message is not displayed).[/size]

Whenever there is an error, I see two alerts displayed.

For a long time I was more than sure, that this is caused by CButtonsColumns’s button issuing two separate AJAX calls. And that’s why I’ve been looking all these resources on “yii ajax called twice”. But then I’ve checked “Network” page in Chrome’s dev tools and I can clearly see, that there is only one AJAX call issued!

This is beyond my knowledge. How it is possible that two alerts are displayed? If there is cleary one AJAX call, how can there be two executions of "success" event"?

(tested in three different browsers – IE, FF, Ch – all after cache purge and restart)

How to avoid this or workaround this problem? As you can see from the code, I’ve been trying to introduce some solutions found (with disabling live and adding unique ID). Both failed.[/s]

I still don’t understand, how two event handlers bind the same element issues only one AJAX call, but problem was solved, so this is off-topic.