How to stop jquery context menu when div is empty?

268 views Asked by At

I am trying Jquery Context Menu. Its working fine. My Code is as below

$(function () {
                            $.contextMenu({
                                selector: '.droppable',
                                callback: function (key, options) {
                                    if (key == "delete") {
                                        if ($(this).html() != "") {
                                            $(this).html("");
                                            deleteKey($(this).attr("id"));
                                        }
                                    }
                                },
                                items: {
                                    "delete": { name: "Delete", icon: "delete" }
                                }
                            });


                        });

Now I want is not to open menu when ($(this).html()=="").

Can I prevent the menu from opening on right click when the container's html is blank?

Thanks in advance.

Vidhin

1

There are 1 answers

0
Vidhin On

OK,

I got the solition.

I need to run a code everytime when there is change in html of the conte

 if ($(this).html() == "") {
                                $("#" + $(this).attr("id")).contextMenu(false);
                            }

Thanks.