【问题标题】:jQuery on Context Menu Web Forms上下文菜单 Web 表单上的 jQuery
【发布时间】:2016-01-11 16:48:40
【问题描述】:

jQuery 的新手,我正在尝试在 Web 窗体应用程序中添加一个右键菜单 div id = "category" 经过多次谷歌搜索,我想出了这个,但不起作用:

HTML:

 <div id ="category">
    <span class="categoryheading">
        <span id="catHide<%#Category %>" class="hidecategory" onclick="$('.cat<%#Category %>').hide(); $('#catHide<%#Category %>').hide(); $('#catShow<%#Category %>').show();">
        </span>
      <span id="catShow<%#Category %>" style="display: none;" class="showcategory" onclick="$('.cat<%#Category %>').show();  $('#catShow<%#Category %>').hide(); $('#catHide<%#Category %>').show();">
        </span>
    <%#Eval("GroupName").ToString() != "" ? Eval("GroupName") : "No Category" %>
   </span>
</div>

jQuery

  // Allow context menu on Category
        $("#category").contextMenu({
            items: {
                ExpandAll:{
                    name: "collapse",
                    title: "Collapse All",
                    alert: ("Test - It Works!!")},
                CollapseAll:{
                    name: "expand", 
                    title: "Expand All",
                    alert: ("Test - It works")}
            }
        });

非常感谢任何关于我哪里出错的指针。

【问题讨论】:

    标签: jquery html webforms


    【解决方案1】:

    您可以使用JQuery-contextify 实现上下文菜单。

    代码:

    HTML:

    <div id="menu">
      Hello
    </div>
    

    Javascript:

    var options = {items:[
      {header: 'Options'},
      {text: 'First Link', href: '#'},
      {text: 'Second Link', onclick: function() {}},
      {divider: true},
      {text: 'Stuff', href: '#'}
    ]}
    $('#menu').contextify(options);
    

    【讨论】:

    • 感谢您的回答@Léo Martin 我收到消息说 Object 不支持属性或方法 'contextify'"(“AddEventListener”也不起作用。)
    猜你喜欢
    • 2013-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多