0

現在、カレンダー形式のページがあり、右クリックして JQuery を使用して contextMenu を表示します。意図したとおりに動作しています。

ユーザーが要素をタブで移動するときに contextMenu を表示する必要があるシナリオがあります。次のコードを使用して、要素の onFocus にコンテキスト メニューを表示しようとしています。

動作しないコードonFocus:

$("a").focus(function (e) {
    // below for anchor element finding the parent which is "li" element with specific class name
    e.preventDefault();
    var parent = $(this).closest('.someclass');
    if (parent.length > 0) {
        //debugger;
        $(".someclass").enableContextMenu(true); // this is not working
    }
    //return false;
});

マウスの右クリックの作業コード

$(".someclass").contextMenu( {
            menu: "notOpenedTasks"
            //, leftButton: true
        },
        function (action, el, pos) {
            contextMenuWork(action, el, pos);
        }
).enableContextMenu();

これが不可能な場合、または私が間違っていることを教えてください。

PS: 私は xplain を明確に申し訳ないと思っています: jquery.contextMenu.js ファイルを使用して、ユーザーが要素を右クリックしたときにコンテキスト メニューを表示します。以下のように定義されたコンテキストメニュー
'ul id="notOpenedTasks" class="contextMenu" style="display:none;"' -li class="Information">Information -li class="Justification">Justification -li class="Document" >Document -/ul
と "li" 要素がこのように定義されています

...だから何をするか.......それは、「someclass」属性を持つ要素に対して「notOpenedTasks」コンテキストメニューを開くと言い、以下のコードはこれを行います...

コンテキストメニューをバインドする以下のコード:

 $(".someclass").contextMenu( { // binds context menu for these class items
            menu: "notOpenedTasks"  // tells which menu
            //, leftButton: true
        },
        function (action, el, pos) { // any subroutine to call
            contextMenuWork(action, el, pos);
        }
   ).enableContextMenu(); // enables context menu


上記のコードは完全に機能します.....今の要件は、ユーザーがタブを押してその要素に到達したときに同じコンテキストメニューを開く必要があることです(要素がフォーカスされたときにこの特定のコンテキストメニューを開くことを理解しようとしています).

何か案は....

4

0 に答える 0