Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8025769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:16:21+00:00 2026-06-04T23:16:21+00:00

Anyone knows a way to listen for clicks on magento tabs with javascript on

  • 0

Anyone knows a way to listen for clicks on magento tabs with javascript on the backend, say you want to do something everytime someone clicks a tab on the edit customer page. adminhtml/tabs.js has this:

    tabMouseClick : function(event) {
    var tab = Event.findElement(event, 'a');

    // go directly to specified url or switch tab
    if ((tab.href.indexOf('#') != tab.href.length-1)
        && !(Element.hasClassName(tab, 'ajax'))
    ) {
        location.href = tab.href;
    }
    else {
        this.showTabContent(tab);
    }
    Event.stop(event);
},  

But no use, anyone has any idea? I also tried using standard prototype js observer:

Event.observe("product_info_tabs", "click", function () 
{ alert(1); 
});  

Did not do anything either. The solution should not modify the core, since this would add many problems with upgrades and maybe future magento versions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:16:22+00:00Added an answer on June 4, 2026 at 11:16 pm

    To listen for clicks on Magento tabs (varienTabs) in the backend, you only need to add your custom observers to the existing ones. Using your example (“edit customer page” in backend) this would be:

    var myTabs = $$("#customer_info_tabs li a.tab-item-link");
    for (var i = 0; i < myTabs.length; i++) {
        Event.observe(myTabs[i], "click", function (event) {
            var tab = Event.findElement(event, "a");
            // insert your custom code here
            alert(tab.id);
            Event.stop(event);
        });
    }
    

    To implement custom observers without changing the core files (breaking upgradability), you could override the appropriate admin controller action.

    For example, override Mage_Adminhtml_CustomerController::editAction():

    <!-- app/code/local/My/Adminhtml/etc/config.xml -->
    <config>
        <modules>
            <My_Adminhtml>
                <version>0.1.0</version>
            </My_Adminhtml>
        </modules>
        <admin>
            <routers>
                <adminhtml>
                    <args>
                        <modules>
                            <My_Adminhtml before="Mage_Adminhtml">My_Adminhtml</My_Adminhtml>
                        </modules>
                    </args>
                </adminhtml>
            </routers>
        </admin>
    </config>
    

    Next, define your custom admin controller:

    // app/code/local/My/Adminhtml/controllers/CustomerController.php
    require 'Mage/Adminhtml/controllers/CustomerController.php';
    class My_Adminhtml_CustomerController extends Mage_Adminhtml_CustomerController
    {
        public editAction()
        {
            // copy of Mage_Adminhtml_CustomerController::editAction() code here
        } 
    }
    

    Finally, in the overridden action, create an additional text block containing your custom observer script and append that block to the layout. For example at the end of editAction insert something like this:

        :
        $this->loadLayout();
        $oBlock = $this->getLayout()->createBlock('core/text')->setText('
             <script type="text/javascript">
                var myTabs = $$("#customer_info_tabs li a.tab-item-link");
                for (var i = 0; i < myTabs.length; i++) {
                    Event.observe(myTabs[i], "click", function (event) {
                        var tab = Event.findElement(event, "a");
                        alert(tab.id);
                        Event.stop(event);
                    });
                }
             </script>
        ');
        $this->getLayout()->getBlock('left')->append($oBlock);
        $this->renderLayout();
        :
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone knows a way to run a c# application without a window popping up(either
Does anyone knows any way to display the New Indian Rupee sumbol. Following the
I was wondering if anyone knows a way to prevent building unneeded device drivers
I was wondering if anyone knows an easy way to do this. I have
I'm curious if anyone knows of a way to easily get a double border
Anyone who knows a good way to generate/create a barcode from a String in
Does anyone know any way to update the resources (images, text files, UI .nib
Does anyone know a way to get the mean amplitude of a .wav file
Does anyone know a way to get Firefox to crop the corners if the
Does anyone know a way to determine if a Rails association has been eager

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.