Project

General

Profile

Actions

Feature #17607

open

More than one ContextMenu on single page

Added by Jan Strnádek over 10 years ago. Updated over 10 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Core Plugins
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

We have to use multiple queries on single page ( it's quite ugly code yet :) ) and we found problem - multiple context menus in one page (practically in multiple tabs), current behaviour is dimensioned for one menu. We rewrote it as Jquery plugin. We're thinking, the new version can be easy extends with other abilities (for example - handling window resizing and change position of menu elements, different events).

Example (output) javascript:

//<![CDATA[
$('#issue_list').contextMenu({ url: '/issues/context_menu''});
//]]>

Example helper:

  def context_tab_menu(url, el)
    unless @context_tab_menu_included
      content_for :header_tags do
        javascript_include_tag('context_menu') +
          stylesheet_link_tag('context_menu')
      end
      if l(:direction) == 'rtl'
        content_for :header_tags do
          stylesheet_link_tag('context_menu_rtl')
        end
      end
      @context_tab_menu_included = true
    end
    javascript_tag "$('#{el}').contextMenu({ url: '#{ url_for(url) }'});" 
  end

Template:

<%= context_tab_menu issues_context_menu_path, '#issue_list' %>

Note: The first element is div around form element it's because we're using ajax to refresh query result (multiple queries), we have to bind context menu handler on it.


Files

context_menu.js (6.48 KB) context_menu.js Context Menu javascript Jan Strnádek, 2014-08-04 13:07
Actions #1

Updated by Etienne Massip over 10 years ago

  • Target version set to Candidate for next major release
Actions

Also available in: Atom PDF