0

I have an noob issue with javascript. I did search the internet how to add a url in javascript, but I cannot figure it out.

I have the following items, but I want it clickable with an url behind it. Does anyone know how to do this in the following code.

$(function(){
$.contextMenu({
    selector: '.context-menu-one', 
    trigger: 'left',

    items: {
        "Ship": {name: "Ship Expedite", icon: "paste"},
        "Request": {name: "Request information", icon: "edit"},
        "Reminder": {name: "Send reminder", icon: "reminder"},
        "Inbound": {name: "Request Inboud", icon: "copy"},
        "delete": {name: "Delete expedite", icon: "delete"},
        "sep1": "---------",


    }

});

});

Marios
  • 41
  • 10
  • Possible duplicate of [How can I make a page redirect using jQuery?](http://stackoverflow.com/questions/503093/how-can-i-make-a-page-redirect-using-jquery) – Rajesh Mar 23 '16 at 06:48
  • what does your `$.contextMenu` do? an you add your HTML? – Rajshekar Reddy Mar 23 '16 at 06:50
  • 1
    According to the documentation (https://swisnl.github.io/jQuery-contextMenu/demo/callback.html) there is a callback option you could use (together with window.location). – Maffelu Mar 23 '16 at 06:51
  • it is actually a jquery menu from here: https://swisnl.github.io/jQuery-contextMenu//demo/trigger-left-click.html – Marios Mar 23 '16 at 06:55

1 Answers1

0

The context menu provides a callback.

 items: {
    "Ship": {
        name: "Ship Expedite", 
        icon: "paste",
        callback: function(key, options) {
          // Do your page redirection here.
          window.location.href('www.yoursite.com/shippingpage');
     }},
    "Request": {name: "Request information", icon: "edit",
       callback: function(key, options) {
          // Do your page redirection here.
          window.location.href('www.yoursite.com/requestpage');
     }},
    "Reminder": {name: "Send reminder", icon: "reminder"},
    "Inbound": {name: "Request Inboud", icon: "copy"},
    "delete": {name: "Delete expedite", icon: "delete",
        callback: function(key, options) {
          // delete item or whatever using ajax possibly?
          // eg. $.post('www.yoursite.com/deleteitem',{id:key});
     }}
    },
    "sep1": "---------",


}
Kylie
  • 11,421
  • 11
  • 47
  • 78