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 8457591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:50:49+00:00 2026-06-10T12:50:49+00:00

I was developed a plugin for context menu of different div <div> <div class=’first’>some

  • 0

I was developed a plugin for context menu of different div

<div>
  <div class='first'>some data</div>
  <div class='second'>some data</div>
  <div class='third'>some data</div>
  <div class='fourth'>some data</div>
</div>

and menu to display as context menu

<ul id='cmenu'>
 <li id='menuItem1'>Item1</li>
<li id='menuItem2'>Item1</li>
<li id='menuItem3'>Item1</li>
<li id='menuItem4'>Item1</li>
<li id='menuItem5'>Item1</li>
<li id='menuItem6'>Item1</li>
</ul>

and my plugin is.

How this plugin works is change the list of menuitems for every division and as the callbacks for menu Items are also change.

(function($) {
    $.fn.cnxtmenu = function(options) {
        var defaults = {
            'menuid' : '',
            item1 : function() {
            },
            item2 : function() {
            },
            item3 : function() {
            },
            item4 : function() {
            },
            item5 : function() {
            },
            item6 : function() {
            },
        }, opt = $.extend({}, defaults, options);
        console.log(opt);
        var mid = '#'+opt.menuid, seldiv;
        this.live({
            "contextmenu" : function(e) {
                //console.log(this);
                seldiv = $(this);
                if ($(this).hasClass('first')) {

                    //change the menu list

                } else if($(this).hasClass('second')){


                // change the menu list to display different items 

                } 
                else if($(this).hasClass('file-list')){
                //differ list

                }
                else if($(this).hasClass('dstore_file-list')){
                    //differ menu list
                }

                $(mid).css({
                    top : e.pageY + 'px',
                    left : e.pageX + 'px'
                }).show();
                return false;
            }
        });

        $(mid).children('li').unbind('click').click(function(e) {
            e.stopPropagation();
            e.preventDefault();
            //console.log(file + "at switch");
            switch(this.id) {
                case 'menuItem1':
                    opt.item1(this, seldiv);
                    break;
                case 'menuItem2':
                    opt.item2(this, seldiv);
                    break;
case 'menuItem3':
                    opt.item3(this, seldiv);
                    break;
case 'menuItem4':
                    opt.item4(this, seldiv);
                    break;
case 'menuItem5':
                    opt.item5(this, seldiv);
                    break;
case 'menuItem6':
                    opt.item6(this, seldiv);
                    break;


            }
            $(mid).hide();
            return false;
        });

        $(mid).click(function() {
            $(mid).hide();
        });
        $(document).click(function() {
            $(mid).hide();
        });

    }
})(jQuery);

and I am using this plugin like this.

$('.first').cnxtmenu({menuid:'cmenu',
item1:some callbacks
...});

for all the three div assign different callbacks.

my problem is callbacks are not differing for the selectors.
and callbacks are triggering many times.

help me whats wrong in my code please

thanks in advance.

  • 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-10T12:50:51+00:00Added an answer on June 10, 2026 at 12:50 pm

    You assigning callbacks onload time of script in your plugin, so the only last assigned callbacks will work.

    The solution is you have to assign the callbacks inside the contextmenu function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have developed a Thunderbird (11) plugin that allows us to save the content
I developed a plugin with Settings link that was working fine in WordPress 2.7.
I am working with python plugins for qgis .I developed the plugin same as
I developed an Eclipse plugin (a view) using the plugin development version of Eclipse.
I have developed a maven plugin that downloads the release notes from JIRA. It's
I would like to use the Hibernate3 plugin for Maven (developed by Codehaus) but
I am writing a custom editor in a plugin, and I developed it in
I developed an Android PhoneGap Plugin. The plugin is successfully getting called, but the
I'm using the Colorbox lightbox plugin to display lightboxes with Outside HTML (Ajax) on
Context I have a div with overflow: auto property. In this div , I

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.