Counters introduction

To append a counter to the menu items that have a submenu, include the "counters" add-on .js and .css files and use the counters options.

<head>
   <script src="path/to/jquery.js" type="text/javascript"></script>
   <script src="path/to/jquery.mmenu.min.js" type="text/javascript"></script>
   <script src="path/to/jquery.mmenu.counters.min.js" type="text/javascript"></script>
   <link href="path/to/jquery.mmenu.css" type="text/css" rel="stylesheet" />
   <link href="path/to/jquery.mmenu.counters.css" type="text/css" rel="stylesheet" />
   <script type="text/javascript">
      $(document).ready(function() {
         $("#my-menu").mmenu({
            counters: {
               // counters options
            }
         });
      });
   </script>

Example

Give it a go, change the options below and see how it affects the menu in the example on the right.

  • Append a counter to the menu items.
  • Works great with:
  • Prepend a searchfield to the menu.
<script type="text/javascript">
   jQuery(document).ready(function( $ ) {

   });
</script>
Dependencies:
  • Core (on-canvas).
Works great with:

Options for the "counters" add-on

Option Default value Datatype Description
counters A map of options or true for counters.add and counters.update.
{
add false Boolean Whether or not to automatically append a counter to each menu item that has a submenu.
addTo "panels" String Where to add the counters.
Possible values: "panels" and a valid jQuery selector.
update false Boolean Whether or not to automatically count the number of items in the submenu.
}

Configuration for the "counters" add-on

The "counters" add-on has no configuration options, it does add an object to the classNames option.

$.mmenu.configuration.classNames.counters = {
   counter: "Counter"
};

API methods for the "counters" add-on

The "counters" add-on has no API methods.

SCSS variables for the "counters" add-on

Variable Default value Datatype Description
1 For the actual value, the datatype and a description, have a look at the default variable values reference.
$mm_counterWidth $mm_btnSize 1 CSS value The width of counters.

SCSS mixins for the "counters" add-on

Mixin( arguments ) Default value Datatype Description
1 The $class argument is not a classname but a CSS selector, therefor you must include the preceding dot. If not an empty string, make sure to add the specified classname to the extensions option when firing the plugin.
2 For the actual value, the datatype and a description, have a look at the default variable values reference.
mm_colors_counters Include this mixin to create a custom color scheme for the "counters" add-on.
(
$class 1 "" String The classname to add to the CSS selectors. If left empty, the new CSS rules will override the default settings.
$textColor $mm_dimmedTextColor 2 The color for text in the counters.
)

Next add-on:
Dividers