Coder Social home page Coder Social logo

Comments (3)

rodneyrehm avatar rodneyrehm commented on May 24, 2024 1

I couldn't find how to do this in your documentation and please forgive me for asking what is most likely a very simple solution, but I am designer by trade who is learning to use JQuery.

never apologize for asking a question. just don't take it personally when someone replies a link with a touch of RTFM. :)

You have several options of going about this. Here are the two simple ones…

Define a callback for each item:

$(function(){
    $.contextMenu({
        selector: '.context-menu-view',
        className: 'title-View',
        trigger: 'hover',
        items: {
            "HTML": {name: "HTML", callback: function(){ window.open("/some.html"); }},
            "PDF": {name: "PDF", callback: function(){ window.open("/some.pdf"); }},
            "Excel": {name: "Excel", callback: function(){ window.open("/some.xls"); }}
        }
    });
});

or you could use a central callback and provide yourself some custom data:

$(function(){
    $.contextMenu({
        selector: '.context-menu-view',
        className: 'title-View',
        trigger: 'hover',
        callback: function(key, options) {
            window.open(options.items[key].someURL);
        },
        items: {
            "HTML": {name: "HTML", someURL: "foobar.html"},
            "PDF": {name: "PDF", someURL: "foobar.pdf"},
            "Excel": {name: "Excel", someURL: "foobar.xls"}
        }
    });
});

from jquery-contextmenu.

nutlessNeo avatar nutlessNeo commented on May 24, 2024

Thank you. Yes, I did my due diligence and scoured the documentation for how to implement this, but did not see anything. This worked great, however, how would I get the page to open in the parent window instead of a new one? Sorry I didn't make that clear in my first post.

from jquery-contextmenu.

rodneyrehm avatar rodneyrehm commented on May 24, 2024

"parent window" being the window containing a frameset? top.location.href = 'new-url.html';
"parent window" being the window that opened a popup within your contextMenu is executed? opener.location.href = 'new-url.html';

from jquery-contextmenu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.