diff --git a/dev/js/runner/all.html b/dev/js/runner/all.html
index 99d4799..52f996f 100644
--- a/dev/js/runner/all.html
+++ b/dev/js/runner/all.html
@@ -39,6 +39,7 @@
         'spec/buttongroupSpec',
         'spec/datepickerSpec',
         'spec/menuSpec',
+        'spec/alwaysMenuSpec',
         'spec/selectMenuSpec',
         'spec/panelSpec',
         'spec/viewSpec',
diff --git a/dev/js/runner/alwaysMenu.html b/dev/js/runner/alwaysMenu.html
new file mode 100644
index 0000000..533e4da
--- /dev/null
+++ b/dev/js/runner/alwaysMenu.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Spec Runner for Menu Helper</title>
+  <link rel="shortcut icon" type="image/png" href="../lib/jasmine-2.1.1/jasmine_favicon.png">
+  <link rel="stylesheet" href="../lib/jasmine-2.1.1/jasmine.css">
+  <script src="../lib/require.js"></script>
+  <script>
+    require.config({
+      baseUrl: "../src",
+      paths: {
+        "lib" : "../lib",
+        "spec" : "../spec",
+        "jlib" : "lib/jasmine-2.1.1",
+        "jasmine" : ['../lib/jasmine-2.1.1/jasmine'],
+        "jasmine-html": ['../lib/jasmine-2.1.1/jasmine-html'],
+        "jasmine-boot": ['../lib/jasmine-2.1.1/boot']
+      },
+      shim : {
+        'jasmine-html' : {
+          deps : ['jasmine']
+        },
+        'jasmine-boot' : {
+          deps : ['jasmine','jasmine-html']
+        }
+      }
+    });
+    require(['jasmine-boot'], function () {
+      require([
+        'spec/alwaysMenuSpec'
+     ],
+      function () {
+        window.onload();
+      });
+    });
+    </script>
+</head>
+<body>
+</body>
+</html>
diff --git a/dev/js/spec/alwaysMenuSpec.js b/dev/js/spec/alwaysMenuSpec.js
new file mode 100644
index 0000000..f849ebd
--- /dev/null
+++ b/dev/js/spec/alwaysMenuSpec.js
@@ -0,0 +1,1469 @@
+define(
+  ['alwaysmenu', 'menu/item', 'menu/prefix', 'menu/lengthField', 'alwaysentry'],
+  function (alwaysMenuClass, menuItemClass, prefixClass, lengthFieldClass, alwaysEntryClass) {
+ 
+    //These class definitions were taken from menuSpec for a guideline on how to procede
+
+    // The OwnAlwaysMenu item
+    const OwnAlwaysMenuItem = {
+      create : function (params) {
+        return Object.create(menuItemClass).upgradeTo(OwnAlwaysMenuItem)._init(params);
+      },
+      content : function (content) {
+        if (arguments.length === 1) {
+	        this._content = content;
+        };
+        return this._content;
+      },
+      _init : function (params) {
+        if (params[0] === undefined)
+	        throw new Error("Missing parameters");
+
+        this._content = document.createTextNode(params[0]);
+        this._lcField = ' ' + this.content().textContent.toLowerCase();
+
+        return this;
+      }
+    };
+
+    // The OwnAlwaysMenu
+    let OwnAlwaysMenu = {
+      create : function (list) {
+        return alwaysMenuClass.create(list, { itemClass : OwnAlwaysMenuItem } )
+	        .upgradeTo(OwnAlwaysMenu);
+      }
+    };
+
+
+
+    // HintMenuItem
+    const HintMenuItem = {
+      create : function (params) {
+        return Object.create(menuItemClass)
+	        .upgradeTo(HintMenuItem)
+	        ._init(params);
+      },
+      content : function (content) {
+        if (arguments.length === 1) {
+	        this._content = content;
+        };
+        return this._content;
+      },
+      _init : function (params) {
+        if (params[0] === undefined || params[1] === undefined)
+	        throw new Error("Missing parameters");
+
+        this._name   = params[0];
+        this._action = params[1];
+        this._lcField = ' ' + this._name.toLowerCase();
+
+        if (params.length > 2) {
+	        this._desc = params[2];
+	        this._lcField += " " + this._desc.toLowerCase();
+        };
+        
+        return this;
+      },
+
+      name : function () {
+        return this._name;
+      },
+      action : function () {
+        return this._action;
+      },
+      desc : function () {
+        return this._desc;
+      },
+      element : function () {
+        // already defined
+        if (this._el !== undefined)
+	        return this._el;
+
+        // Create list item
+        var li = document.createElement("li");
+        li.setAttribute("data-action", this._action);
+
+        // Create title
+        var name =  document.createElement("strong");
+        name.appendChild(document.createTextNode(this._name));
+        
+        li.appendChild(name);
+
+        // Create description
+        if (this._desc !== undefined) {
+	        var desc = document.createElement("span");
+	        desc.appendChild(document.createTextNode(this._desc));
+	        li.appendChild(desc);
+        };
+        return this._el = li;
+      }
+    };
+
+
+    // HintMenu
+    const HintMenu = {
+      create : function (context, list) {
+        var obj = alwaysMenuClass.create(list, {itemClass : HintMenuItem} )
+	          .upgradeTo(HintMenu);
+        obj._context = context;
+        return obj;
+      }
+    };
+
+
+    // The ComplexMenuItem
+    const ComplexMenuItem = {
+      create : function (params) {
+        return Object.create(menuItemClass)
+	        .upgradeTo(ComplexMenuItem)
+	        ._init(params);
+      },
+      content : function (content) {
+        if (arguments.length === 1) {
+	        this._content = content;
+        };
+        return this._content;
+      },
+      _init : function (params) {
+        if (params[0] === undefined)
+	        throw new Error("Missing parameters");
+
+        var r = document.createElement('div');
+        for (var i = 1; i <= params.length; i++) {
+	        var h = document.createElement('h' + i);
+	        h.appendChild(document.createTextNode(params[i-1]));
+	        r.appendChild(h);
+        };
+
+        this._content = r;
+        this._lcField = ' ' + this.content().textContent.toLowerCase();
+
+        return this;
+      }
+    };
+
+
+    describe('KorAP.AlwaysMenu', function () {
+      var list = [
+        ["Constituency", "c=", "Example 1"],
+        ["Lemma", "l="],
+        ["Morphology", "m=", "Example 2"],
+        ["Part-of-Speech", "p="],
+        ["Syntax", "syn="]
+      ];
+
+      var listMultiPrefix = [
+        ["PP","PP ","Personal Pronoun"],
+        ["PPP","PPP ","Personal Pronoun, Plural"],
+        ["PPPA","PPPA ","Personal Pronoun, Plural, Acc."],
+        ["PPPD","PPPD ","Personal Pronoun, Plural, Dative"],
+        ["PPPR","PPPR ","Personal Pronoun, Plural, Direct"],
+        ["PPPO","PPPO ","Personal Pronoun, Plural, Oblique"],
+        ["PPS","PPS ","Personal Pronoun, Singular"],
+        ["PPSA","PPSA ","Personal Pronoun, Singular, Accusative"],
+        ["PPSD","PPSD ","Personal Pronoun, Singular, Dative"],
+        ["PPSR","PPSR ","Personal Pronoun, Singular, Direct"],
+        ["PPSN","PPSN ","Personal Pronoun, Singular, Nominative"],
+        ["PPSO","PPSO ","Personal Pronoun, Singular, Oblique"]
+      ];
+      
+      var demolist = [
+        ['Titel', 'title'],
+        ['Untertitel', 'subTitle'],
+        ['Veröffentlichungsdatum', 'pubDate'],
+        ['Länge', 'length'],
+        ['Autor', 'author']
+      ];
+
+      var demolonglist = [
+        ['Titel', 'title'],
+        ['Untertitel', 'subTitle'],
+        ['Veröffentlichungsdatum', 'pubDate'],
+        ['Länge', 'length'],
+        ['Autor', 'author'],
+        ['Genre', 'genre'],
+        ['corpusID', 'corpusID'],
+        ['docID', 'docID'],
+        ['textID', 'textID'],
+      ];
+
+      it('should be initializable', function () {
+        var list = [
+	        ["Constituency"],
+	        ["Lemma"],
+	        ["Morphology"],
+	        ["Part-of-Speech"],
+	        ["Syntax"]
+        ];
+
+        var menu = OwnAlwaysMenu.create(list);
+        menu._firstActive = true;
+        expect(menu.itemClass()).toEqual(OwnAlwaysMenuItem);
+        expect(menu._notItemElements).toEqual(4);
+        expect(menu.element().getElementsByClassName("pref").length).toEqual(2); //TODO: new scss = new class
+        expect(menu.element().getElementsByClassName("pref")[1].innerHTML).toEqual("Speichern");
+        expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern");
+        //expect(menu.element().childNodes[3].innerHTML).toEqual("Speichern"); //?
+        // getElementsByClassName funktioniert bei allen Kindern.
+
+
+        // view
+        menu.show();
+
+        expect(menu.alwaysEntry().active()).toBe(false);
+      });
+
+      it('should be visible', function () {
+        var menu = HintMenu.create("cnx/", list);
+        expect(menu.removeItems()).toBe(undefined);
+        menu.limit(3);
+
+        expect(menu.show()).toBe(true);
+
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
+        expect(menu.element().getElementsByTagName("li")[1].getAttribute("data-action")).toEqual("l=");
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+
+        // Check boundaries
+        expect(menu.element().getElementsByTagName("li")[0].classList.contains("no-more")).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[1].classList.contains("no-more")).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[2].classList.contains("no-more")).toBe(false);
+      });
+
+      it('should be filterable', function () {
+        var menu = HintMenu.create("cnx/", list);
+        menu.limit(3);
+        expect(menu.prefix("o").show()).toBe(true);
+        expect(menu.alwaysEntryValue("o").alwaysEntryValue()).toEqual("o");
+        expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("o");
+        expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+
+        // Check boundaries
+        expect(menu.element().getElementsByTagName("li")[0].classList.contains("no-more")).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[1].classList.contains("no-more")).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[2].classList.contains("no-more")).toBe(true);
+
+        menu.limit(2);
+
+        expect(menu.prefix("o").show()).toBe(true);
+        expect(menu.alwaysEntryValue("o").alwaysEntryValue()).toEqual("o");
+        expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("o");
+        expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+        expect(menu.element().getElementsByTagName("li")[2]).toBe(undefined);
+
+        // Check boundaries
+        expect(menu.element().getElementsByTagName("li")[0].classList.contains("no-more")).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[1].classList.contains("no-more")).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[2]).toBe(undefined);
+
+        expect(menu.prefix("e").show()).toBe(true);
+        expect(menu.alwaysEntryValue("e").alwaysEntryValue()).toEqual("e");
+        expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("e");        
+        expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
+        expect(menu.element().getElementsByTagName("li")[2]).toBe(undefined);
+
+        menu.limit(5);
+        expect(menu.prefix("a").show()).toBe(true);
+        expect(menu.alwaysEntryValue("a").alwaysEntryValue()).toEqual("a");
+        expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("a");        
+        expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Ex<mark>a</mark>mple 1</span>");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Lemm<mark>a</mark></strong>");
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Ex<mark>a</mark>mple 2</span>");
+        expect(menu.element().getElementsByTagName("li")[3].innerHTML).toEqual("<strong>P<mark>a</mark>rt-of-Speech</strong>");
+        expect(menu.element().getElementsByTagName("li")[4].innerHTML).toEqual("<strong>Synt<mark>a</mark>x</strong>");
+        expect(menu.element().getElementsByTagName("li")[5]).toBe(undefined);
+      });
+
+
+      it('should be nextable', function () {
+        var menu = HintMenu.create("cnx/", list);
+        menu._firstActive = true;
+
+        expect(menu._prefix.active()).toBe(false);
+
+        // Show only 3 items
+        menu.limit(3);
+        expect(menu.show()).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Activate next (1)
+        menu.next();
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
+        expect(menu.shownItem(1).active()).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Activate next (2)
+        menu.next();
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+        expect(menu.shownItem(2).active()).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Activate next (3)
+        // scroll!
+        menu.next();
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Lemma</strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+        expect(menu.shownItem(2).active()).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Activate next (4)
+        menu.next();
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Syntax</strong>");
+        expect(menu.shownItem(2).active()).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Activate next (5) - Entry / Speichern
+        menu.next();
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Syntax</strong>");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(true);
+
+        // Activate next (6) - ROLL
+        menu.next();
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Active next (7)
+        menu.next();
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
+        expect(menu.shownItem(1).active()).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        expect(menu._prefix.active()).toBe(false);
+      });
+
+      it('should be nextable without active field', function () {
+        var menu = HintMenu.create("cnx/", list);
+        menu.limit(3);
+        expect(menu.show()).toBe(true);
+        menu.next();
+        expect(menu.shownItem(0).active()).toEqual(true);
+      });
+
+
+      it('should be prevable', function () {
+        var menu = HintMenu.create("cnx/", list);
+        menu._firstActive = true;
+        menu.limit(3);
+        expect(menu.show()).toBe(true);
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.alwaysEntryValue()).toBe("");
+
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+
+        // Activate prev (1) - roll to bottom
+        menu.prev();
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(true);
+
+        // Activate prev (2)
+        menu.prev();
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Syntax</strong>");
+        expect(menu.shownItem(2).active()).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Activate prev (3)
+        menu.prev();
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+        expect(menu.shownItem(1).active()).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Syntax</strong>");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Activate prev (4)
+        menu.prev();
+        expect(menu.shownItem(0).name()).toEqual("Morphology");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).name()).toEqual("Syntax");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Activate prev (5)
+        menu.prev();
+        expect(menu.shownItem(0).name()).toEqual("Lemma");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Morphology");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).name()).toEqual("Part-of-Speech");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Activate prev (6)
+        menu.prev();
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Lemma");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).name()).toEqual("Morphology");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Activate next (7)
+        menu.next();
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Lemma");
+        expect(menu.shownItem(1).active()).toBe(true);
+        expect(menu.shownItem(2).name()).toEqual("Morphology");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Activate prev (8)
+        menu.prev();
+
+        // Activate prev (9) - Roll again
+        menu.prev();
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Lemma");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).name()).toEqual("Morphology");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(true);
+
+        // Activate prev (10)
+        menu.prev()
+        expect(menu.shownItem(0).name()).toEqual("Morphology");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).name()).toEqual("Syntax");
+        expect(menu.shownItem(2).active()).toBe(true);
+        expect(menu.element().getElementsByTagName("li")[3]).toBe(undefined);
+        expect(menu.alwaysEntry().active()).toBe(false);
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.alwaysEntryValue()).toBe("");
+        expect(menu.alwaysEntry().element().innerHTML).toBe("Speichern");
+
+      });
+
+      it('should be prevable without active field', function () {
+        var menu = HintMenu.create("cnx/", list);
+        menu.limit(3);
+        expect(menu.show()).toBe(true);
+        menu.prev();
+        expect(menu.alwaysEntry().active()).toBe(true);
+        expect(menu.shownItem(2).active()).toEqual(false);
+        expect(menu.shownItem(2).lcField()).toEqual(' morphology example 2');
+        menu.prev()
+        expect(menu.shownItem(2).active()).toEqual(true);
+        expect(menu.shownItem(2).lcField()).toEqual(' syntax');
+      });
+
+      it('should be navigatable and filterable (prefix = "o")', function () {
+        var menu = HintMenu.create("cnx/", list);
+        menu._firstActive = true;
+        menu.limit(2);
+
+        expect(menu.prefix("o").show()).toBe(true);
+        expect(menu.alwaysEntryValue("o").alwaysEntryValue()).toBe("o");
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Morphology");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Next (1)
+        menu.next();
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Morphology");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+        expect(menu.shownItem(1).active()).toBe(true);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Next (2)
+        menu.next();
+        expect(menu.shownItem(0).name()).toEqual("Morphology");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
+        expect(menu.shownItem(1).active()).toBe(true);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Next (3) - to prefix
+        menu.next();
+        expect(menu.shownItem(0).name()).toEqual("Morphology");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+        expect(menu._prefix.active()).toBe(true);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+         // Next (4) - to entry
+         menu.next();
+         expect(menu.shownItem(0).name()).toEqual("Morphology");
+         expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+         expect(menu.shownItem(0).active()).toBe(false);
+         expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
+         expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
+         expect(menu.shownItem(1).active()).toBe(false);
+         expect(menu.shownItem(2)).toBe(undefined);
+         expect(menu._prefix.active()).toBe(false);
+         expect(menu.alwaysEntry().active()).toBe(true);
+
+        menu.next();
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Morphology");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        expect(menu.prefix("o").show()).toBe(true);
+        expect(menu.alwaysEntryValue("o").alwaysEntryValue()).toBe("o");
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.alwaysEntry().active()).toBe(false);
+      });
+
+
+      it('should be navigatable and filterable (prefix = "ex", "e")', function () {
+        var menu = HintMenu.create("cnx/", list);
+        menu._firstActive = true;
+
+        menu.limit(2);
+        expect(menu.prefix("ex").show()).toBe(true);
+        expect(menu.alwaysEntryValue("ex").alwaysEntryValue()).toBe("ex");
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Morphology");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Next (1)
+        menu.next();
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Morphology");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
+        expect(menu.shownItem(1).active()).toBe(true);
+        expect(menu.shownItem(2)).toBe(undefined);
+        expect(menu.alwaysEntryValue()).toBe("ex");
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Next (2)
+        menu.next();
+
+        expect(menu.prefix()).toEqual('ex');
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+
+        expect(menu.shownItem(1).name()).toEqual("Morphology");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+        expect(menu.alwaysEntryValue()).toBe("ex");
+        expect(menu._prefix.active()).toBe(true);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Reset limit
+        menu.limit(5);
+
+        // Change show
+        expect(menu.prefix("e").show()).toBe(true);
+        expect(menu.alwaysEntryValue("e").alwaysEntryValue()).toBe("e");
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.alwaysEntry().active()).toBe(false);
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Morphology");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Next (1)
+        menu.next();
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.prefix()).toEqual('e');
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Morphology");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
+        expect(menu.shownItem(1).active()).toBe(true);
+        expect(menu.shownItem(2)).toBe(undefined);
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Next (2)
+        menu.next();
+        expect(menu._prefix.active()).toBe(true);
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Morphology");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+        expect(menu._prefix.active()).toBe(true);
+        expect(menu.alwaysEntry().active()).toBe(false);
+
+        // Next (2.5)
+        menu.next();
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Morphology");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.alwaysEntry().active()).toBe(true);
+
+        // Next (3)
+        menu.next();
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.shownItem(0).name()).toEqual("Constituency");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Morphology");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        expect(menu.alwaysEntryValue()).toBe("e");
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.alwaysEntry().active()).toBe(false);
+      });
+
+      it('should be filterable (multiple prefix = "pro sin")', function () {
+        var menu = HintMenu.create("drukola/p=", listMultiPrefix);
+        menu._firstActive = true;
+
+        menu.limit(2);
+        expect(menu.prefix("pro sin").show()).toBe(true);
+        expect(menu.alwaysEntryValue("pro sin").alwaysEntryValue()).toBe("pro sin");
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu.alwaysEntry().active()).toBe(false);
+        expect(menu.shownItem(0).name()).toEqual("PPS");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual(
+          "<strong>PPS</strong><span>Personal <mark>Pro</mark>noun, <mark>Sin</mark>gular</span>"
+        );
+
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("PPSA");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>PPSA</strong><span>Personal <mark>Pro</mark>noun, <mark>Sin</mark>gular, Accusative</span>");
+        expect(menu.shownItem(1).active()).toBe(false);
+
+        expect(menu.shownItem(2)).toBe(undefined);
+      });
+
+      it('should be filterable (trimming = " p")', function () {
+        var menu = HintMenu.create("/p=", listMultiPrefix);
+        // menu._firstActive = true;
+
+        menu.limit(2);
+        expect(menu.show()).toBe(true);
+        menu._prefix.add(" ");
+        menu._entry.add(" ")
+        expect(menu.show()).toBe(true);
+        menu._prefix.add("p")
+        menu._entry.add("p")
+        expect(menu.alwaysEntryValue()).toBe(" p");
+        expect(menu.show()).toBe(true);
+        expect(menu.shownItem(0).name()).toEqual("PP");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual(
+          "<strong><mark>P</mark><mark>P</mark></strong>"+
+            "<span><mark>P</mark>ersonal <mark>P</mark>ronoun</span>"
+        );
+      });      
+ 
+
+
+      it('should ignore navigation with failing prefix', function () {
+        var menu = HintMenu.create("cnx/", list);
+        menu.limit(2);
+        expect(menu.show()).toBe(true);
+
+        menu.next();
+
+        expect(menu.prefix("exit").show()).toBe(true);
+        expect(menu.element().querySelector('li')).toBe(null);
+        expect(menu.shownItem(0)).toBeUndefined();
+        expect(menu._prefix.active()).toBe(true);
+
+        menu.next();
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu._entry.active()).toBe(true);
+
+        menu.next();
+        expect(menu._prefix.active()).toBe(true);
+        expect(menu._entry.active()).toBe(false);
+
+        menu.prev();
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu._entry.active()).toBe(true);
+
+        menu.prev();
+        expect(menu._prefix.active()).toBe(true);
+        expect(menu._entry.active()).toBe(false);
+
+      });
+
+      it('should be navigatable with prefix', function () {
+        var menu = HintMenu.create("cnx/", demolist);
+        menu._firstActive = true;
+
+        menu.limit(3);
+
+        expect(menu.show()).toBe(true);
+        expect(menu.prefix()).toEqual("");
+        expect(menu.alwaysEntryValue()).toEqual("");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(false);
+
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Titel</strong>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertitel</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.shownItem(3)).toBe(undefined);
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(false);
+
+        menu._prefix.add('a');
+        menu._entry.add('a');
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.show()).toBe(true);
+        expect(menu.prefix()).toEqual("a");
+        expect(menu.alwaysEntryValue()).toEqual("a");
+        expect(menu.shownItem(0).name()).toEqual("Autor");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong><mark>A</mark>utor</strong>");
+
+        menu._prefix.add('u');
+        menu._entry.add('u');
+        expect(menu.show()).toBe(true);
+        expect(menu.prefix()).toEqual("au");
+        expect(menu.alwaysEntryValue()).toEqual("au");
+        expect(menu.shownItem(0).name()).toEqual("Autor");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong><mark>Au</mark>tor</strong>");
+
+        menu._prefix.chop();
+        menu._entry.chop();
+        expect(menu.show()).toBe(true);
+        expect(menu.prefix()).toEqual("a");
+        expect(menu.alwaysEntryValue()).toEqual("a");
+        expect(menu.shownItem(0).name()).toEqual("Autor");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong><mark>A</mark>utor</strong>");
+
+        menu._prefix.chop();
+        menu._entry.chop();
+        expect(menu.show()).toBe(true);
+        expect(menu.prefix()).toEqual("");
+        expect(menu.alwaysEntryValue()).toEqual("");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Titel</strong>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertitel</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.shownItem(3)).toBe(undefined);
+
+        // Forward
+        menu._prefix.chop();
+        menu._entry.chop();
+        expect(menu.show()).toBe(true);
+        expect(menu.prefix()).toEqual("");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.alwaysEntryValue()).toEqual("");
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Titel</strong>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertitel</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+        expect(menu.shownItem(2).active()).toBe(false);
+
+        // Forward
+        menu.next();
+        expect(menu.prefix()).toEqual("");
+        expect(menu.alwaysEntryValue()).toEqual("");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Titel</strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertitel</strong>");
+        expect(menu.shownItem(1).active()).toBe(true);
+        expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.shownItem(3)).toBe(undefined);
+
+        // Forward
+        menu.next();
+        expect(menu.prefix()).toEqual("");
+        expect(menu.alwaysEntryValue()).toEqual("");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Titel</strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertitel</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+        expect(menu.shownItem(2).active()).toBe(true);
+        expect(menu.shownItem(3)).toBe(undefined);
+
+        // Forward
+        menu.next();
+        expect(menu.prefix()).toEqual("");
+        expect(menu.alwaysEntryValue()).toEqual("");
+        expect(menu.shownItem(0).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Untertitel</strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Veröffentlichungsdatum");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).name()).toEqual("Länge");
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Länge</strong>");
+        expect(menu.shownItem(2).active()).toBe(true);
+        expect(menu.shownItem(3)).toBe(undefined);
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(false);
+
+        // Forward
+        menu.next();
+        expect(menu.prefix()).toEqual("");
+        expect(menu.alwaysEntryValue()).toEqual("");
+        expect(menu.shownItem(0).name()).toEqual("Veröffentlichungsdatum");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Länge");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Länge</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).name()).toEqual("Autor");
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Autor</strong>");
+        expect(menu.shownItem(2).active()).toBe(true);
+        expect(menu.shownItem(3)).toBe(undefined);
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(false);
+        
+        // Forward
+        menu.next();
+        expect(menu.prefix()).toEqual("");
+        expect(menu.alwaysEntryValue()).toEqual("");
+        expect(menu.shownItem(0).name()).toEqual("Veröffentlichungsdatum");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Länge");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Länge</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).name()).toEqual("Autor");
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Autor</strong>");
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.shownItem(3)).toBe(undefined);
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(true);
+
+        // Forward
+        menu.next();
+        expect(menu.prefix()).toEqual("");
+        expect(menu.alwaysEntryValue()).toEqual("");
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Titel</strong>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertitel</strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
+        expect(menu.element().getElementsByTagName("li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+        expect(menu.shownItem(2).active()).toBe(false);
+      });
+
+
+      it('should be navigatable with a prefix (1)', function () {
+        var menu = HintMenu.create("cnx/", demolist);
+        menu._firstActive = true;
+
+        menu.limit(3);
+
+        expect(menu.show()).toBe(true);
+        expect(menu.prefix()).toEqual("");
+        expect(menu.alwaysEntryValue()).toEqual("");
+
+        // Add prefix in uppercase - but check in lowercase
+        menu.prefix('El');
+        menu.alwaysEntryValue('El');
+        expect(menu.show()).toBe(true);
+
+        expect(menu.prefix()).toEqual("El");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu.alwaysEntryValue()).toEqual("El");
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Forward
+        menu.next();
+        expect(menu.prefix()).toEqual("El");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu.alwaysEntryValue()).toEqual("El");
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(true);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Forward
+        menu.next();
+        expect(menu.prefix()).toEqual("El");
+        expect(menu._prefix.active()).toEqual(true);
+        expect(menu.alwaysEntryValue()).toEqual("El");
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Forward
+        menu.next();
+        expect(menu.prefix()).toEqual("El");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu.alwaysEntryValue()).toEqual("El");
+        expect(menu._entry.active()).toEqual(true);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        menu.prev()
+        expect(menu.prefix()).toEqual("El");
+        expect(menu._prefix.active()).toEqual(true);
+        expect(menu.alwaysEntryValue()).toEqual("El");
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Backward
+        menu.prev();
+        expect(menu.prefix()).toEqual("El");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu.alwaysEntryValue()).toEqual("El");
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(true);
+        expect(menu.shownItem(2)).toBe(undefined);
+      });
+
+
+      it('should be navigatable with a prefix (2)', function () {
+        var menu = HintMenu.create("cnx/", demolist);
+        menu._firstActive = true;
+
+        menu.limit(3);
+        expect(menu.show()).toBe(true);
+        expect(menu.prefix()).toEqual("");
+        menu.prefix('el');
+        expect(menu.alwaysEntryValue()).toEqual("");
+        menu.alwaysEntryValue('el');
+        expect(menu.show()).toBe(true);
+
+        expect(menu.prefix()).toEqual("el");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu.alwaysEntryValue()).toEqual("el");
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Backward
+        menu.prev();
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(true);
+
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+
+        // Backward
+        menu.prev();
+        expect(menu._prefix.active()).toEqual(true);
+        expect(menu._entry.active()).toEqual(false);
+
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Backward
+        menu.prev();
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(true);
+        expect(menu.shownItem(2)).toBe(undefined);
+      });
+
+      it('should be navigatable with a prefix (3)', function () {
+        var menu = HintMenu.create("cnx/", demolist);
+        menu._firstActive = true;
+        menu.limit(3);
+        expect(menu.show()).toBe(true);
+        expect(menu.prefix()).toEqual("");
+        menu.prefix('el');
+        expect(menu.alwaysEntryValue()).toEqual("");
+        expect(menu.alwaysEntry().value()).toEqual("");
+        menu.alwaysEntryValue('el');
+        expect(menu.show()).toBe(true);
+
+        expect(menu.prefix()).toEqual("el");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu.alwaysEntry().value()).toEqual("el");
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Backward
+        menu.prev();
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(true);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Backward
+        menu.prev();
+        expect(menu._prefix.active()).toEqual(true);
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+
+        // Forward
+        menu.next();
+        expect(menu.prefix()).toEqual("el");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(true);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+
+        // Forward
+        menu.next();
+        expect(menu.prefix()).toEqual("el");
+        expect(menu._prefix.active()).toEqual(false);
+        expect(menu._entry.active()).toEqual(false);
+        expect(menu.shownItem(0).name()).toEqual("Titel");
+        expect(menu.element().getElementsByTagName("li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).name()).toEqual("Untertitel");
+        expect(menu.element().getElementsByTagName("li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2)).toBe(undefined);
+      });
+
+
+
+      xit('should scroll to a chosen value after prefixing, if the chosen value is live');
+    });
+
+    describe('KorAP.AlwaysMenu.Entry', function () {
+      it('should be initializable', function () {
+        var p = alwaysEntryClass.create();
+        expect(p.element().classList.contains('pref')).toBeTruthy();
+        expect(p.isSet()).not.toBeTruthy();
+        expect(p.element().innerHTML).toEqual("Speichern");
+        expect(p.value()).toEqual("");
+
+        /*
+          expect(mi.lcField()).toEqual(' baum');
+        */
+        
+      });
+
+      it('should be initializable with a different name', function () {
+        var p = alwaysEntryClass.create("Save");
+        expect(p.element().classList.contains('pref')).toBeTruthy();
+        expect(p.isSet()).not.toBeTruthy();
+        expect(p.element().innerHTML).toEqual("Save");
+        expect(p.value()).toEqual("");
+
+        /*
+          expect(mi.lcField()).toEqual(' baum');
+        */
+        
+      });
+
+      it('should be modifiable', function () {
+        var p = alwaysEntryClass.create();
+        expect(p.value()).toEqual('');
+        expect(p.element().firstChild).toEqual(document.createTextNode("Speichern"));
+
+        // Set string
+        expect(p.value('Test')).toEqual('Test');
+        expect(p.value()).toEqual('Test');
+        expect(p.element().firstChild.nodeValue).toEqual('Speichern');
+
+        // Add string
+        expect(p.add('ified')).toEqual('Testified');
+        expect(p.value()).toEqual('Testified');
+        expect(p.element().firstChild.nodeValue).toEqual('Speichern');
+
+        // Clear string
+        p.clear();
+        expect(p.value()).toEqual('');
+        expect(p.element().firstChild).toEqual(document.createTextNode("Speichern"));
+
+        // Set string
+        expect(p.value('Test')).toEqual('Test');
+        expect(p.value()).toEqual('Test');
+        expect(p.element().firstChild.nodeValue).toEqual('Speichern');
+
+        expect(p.chop()).toEqual('Tes');
+        expect(p.value()).toEqual('Tes');
+        expect(p.element().firstChild.nodeValue).toEqual('Speichern');
+
+        expect(p.chop()).toEqual('Te');
+        expect(p.value()).toEqual('Te');
+        expect(p.element().firstChild.nodeValue).toEqual('Speichern');
+
+        expect(p.chop()).toEqual('T');
+        expect(p.value()).toEqual('T');
+        expect(p.element().firstChild.nodeValue).toEqual('Speichern');
+
+        expect(p.chop()).toEqual('');
+        expect(p.value()).toEqual('');
+        expect(p.element().firstChild).toEqual(document.createTextNode("Speichern"));
+      });
+
+      it('should be activatable', function () {
+        var p = alwaysEntryClass.create();
+        expect(p.value()).toEqual('');
+        expect(p.element().firstChild).toEqual(document.createTextNode("Speichern"));
+
+        expect(p.value('Test')).toEqual('Test');
+        expect(p.element().firstChild.nodeValue).toEqual('Speichern');
+
+        expect(p.active()).not.toBeTruthy();
+        expect(p.element().classList.contains('active')).not.toBeTruthy();
+
+        p.active(true);
+        expect(p.active()).toBeTruthy();
+        expect(p.element().classList.contains('active')).toBeTruthy();
+      });
+    });
+
+    describe('KorAP.AlwaysMenu.Slider', function () {
+
+      var demolonglist = [
+        ['Titel', 'title'],
+        ['Untertitel', 'subTitle'],
+        ['Veröffentlichungsdatum', 'pubDate'],
+        ['Länge', 'length'],
+        ['Autor', 'author'],
+        ['Genre', 'genre'],
+        ['corpusID', 'corpusID'],
+        ['docID', 'docID'],
+        ['textID', 'textID'],
+      ];
+
+      it('should correctly be initializable', function () {
+        var list = [
+	        ["Constituency"],
+	        ["Lemma"],
+	        ["Morphology"],
+	        ["Part-of-Speech"],
+	        ["Syntax"]
+        ];
+
+        var menu = OwnAlwaysMenu.create(list);
+
+        menu._firstActive = true;
+        menu.limit(3);
+
+        expect(menu.show()).toBe(true);
+
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu.slider().offset()).toEqual(0);
+        expect(menu.position).toEqual(0);
+      });
+
+      it('should correctly move on arrow keys', function () {
+        var list = [
+	        ["Constituency"],
+	        ["Lemma"],
+	        ["Morphology"],
+	        ["Part-of-Speech"],
+	        ["Syntax"]
+        ];
+
+        var menu = OwnAlwaysMenu.create(list);
+
+        menu._firstActive = true;
+        menu.limit(3);
+
+        expect(menu.show()).toBe(true);
+
+        menu.next();
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).active()).toBe(true);
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu._entry.active()).toBe(false);
+        expect(menu.slider().offset()).toEqual(0);
+        expect(menu.position).toEqual(1);
+
+        menu.next();
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).active()).toBe(true);
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu._entry.active()).toBe(false);
+        expect(menu.slider().offset()).toEqual(0);
+        expect(menu.position).toEqual(2);
+
+        menu.next();
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).active()).toBe(true);
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu._entry.active()).toBe(false);
+        expect(menu.slider().offset()).toEqual(1);
+        expect(menu.position).toEqual(3);
+
+        menu.next();
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).active()).toBe(true);
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu._entry.active()).toBe(false);
+        expect(menu.slider().offset()).toEqual(2);
+        expect(menu.position).toEqual(4);
+
+        menu.next();
+        expect(menu.shownItem(0).active()).toBe(false);
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu._entry.active()).toBe(true);
+        expect(menu.slider().offset()).toEqual(2);
+        expect(menu.position).toEqual(7);
+
+        menu.next();
+        expect(menu.shownItem(0).active()).toBe(true);
+        expect(menu.shownItem(1).active()).toBe(false);
+        expect(menu.shownItem(2).active()).toBe(false);
+        expect(menu._prefix.active()).toBe(false);
+        expect(menu._entry.active()).toBe(false);
+        expect(menu.slider().offset()).toEqual(0);
+        expect(menu.position).toEqual(0);
+
+        expect(menu.slider()._slider.style.height).toEqual('60%');
+      });
+
+    });
+
+    describe('KorAP.AlwaysMenu.Benchmark', function () {
+      var menu = alwaysMenuClass.create([
+        ['Titel', 'title'],
+        ['Untertitel', 'subTitle'],
+        ['Veröffentlichungsdatum', 'pubDate'],
+        ['Länge', 'length'],
+        ['Autor', 'author']
+      ]);
+
+      menu.limit(3).show();
+
+      // Some actions
+      menu.next();
+      menu.next();
+      menu.prev();
+      menu.prev();
+      menu.prev();
+      
+      menu.pageDown();
+      menu.pageUp();
+
+      // There is no fourth item in the list!
+      menu.prefix('e').show(4);
+      menu.next();
+      menu.next();
+      menu.prev();
+      menu.prev();
+      menu.prev();
+    });
+  });
diff --git a/dev/js/spec/menuSpec.js b/dev/js/spec/menuSpec.js
index 22f3c77..c24a75b 100644
--- a/dev/js/spec/menuSpec.js
+++ b/dev/js/spec/menuSpec.js
@@ -380,6 +380,7 @@
         expect(menu.element().nodeName).toEqual('UL');
         expect(menu.element().classList.contains('visible')).toBeFalsy();
         expect(menu.limit()).toEqual(8);
+        expect(menu._notItemElements).toEqual(3);
 
         menu.limit(9);
         expect(menu.limit()).toEqual(9);
diff --git a/dev/js/src/alwaysentry.js b/dev/js/src/alwaysentry.js
new file mode 100644
index 0000000..f3f7b42
--- /dev/null
+++ b/dev/js/src/alwaysentry.js
@@ -0,0 +1,43 @@
+/**
+ * An entry in menus that is always
+ * displayed, with a string and onClick functionality
+ * uses menu/prefix.js as prototype and doesn't change much, all
+ * functionality comes from the alwaysmenu
+ * 
+ * 
+ * @author Leo Repp
+ */
+
+
+"use strict";
+
+define([
+  'menu/prefix'
+], function (prefixClass) {
+  
+  return {
+
+    /**
+     * Create new always visible menu entry object.
+     * Like a prefix Object, always visible, for some defined action
+     */
+    create : function (text) {
+      const obj = prefixClass.create()
+        .upgradeTo(this)
+        ._init();
+      obj._el.innerHTML = text || "Speichern";
+      //dont forget to adjust alwaysMenuSpec - alwaysEntry!
+      return obj;
+    },
+
+    _update : function () {
+      if (this._string.length!==0){ // I assume that this is a sufficient criterium for infering that the prefix is active
+        this._el.style.bottom="-27px";
+      } else if (this._string.length===0) {
+        this._el.style.bottom="0px";
+      }
+      return this._string; // No need to change the text (=innerHTML)
+    },
+
+  };
+});
diff --git a/dev/js/src/alwaysmenu.js b/dev/js/src/alwaysmenu.js
new file mode 100644
index 0000000..4bcf9da
--- /dev/null
+++ b/dev/js/src/alwaysmenu.js
@@ -0,0 +1,546 @@
+/**
+ * 
+ * A Version of the menu class, that
+ * has an always displayed entry that can be
+ * clicked and contains text
+ * 
+ * This entry button may or may not be displayed on top of objects
+ * lying under (>y) this menu. See alwaysentry update: negative absolute 
+ * y coordinate.
+ * 
+ * @author Leo Repp
+ */
+
+"use strict";
+define([
+  'menu',
+  'menu/item',
+  'menu/prefix',
+  'menu/lengthField',
+  'alwaysentry',
+  'util'
+], function (
+    menuClass,
+    defaultItemClass,
+    defaultPrefixClass,
+    defaultLengthFieldClass,
+    defaultAlwaysEntryClass) {
+
+    return {
+
+    /**
+     * Create new menu with an always visible entry.
+     * @this {AlwaysMenu}
+     * @constructor
+     * @param {Object["like this"]} params Object with attributes prefixCLass, itemClass, lengthFieldClass, alwaysEntryClass
+     * @param {Array.<Array.<string>>} list list of menu items
+     */
+    create : function (list, params) {
+      const obj = menuClass.create(list,params)
+          .upgradeTo(this)
+          ._init(list, params);
+      
+      obj._el.classList.add('alwaysmenu');
+
+      //add entry object and allow for own entryClasses
+      if (params!==undefined && params["alwaysEntryClass"] !== undefined) {
+        obj._entry = params["alwaysEntryClass"].create();
+      } else {
+        obj._entry=defaultAlwaysEntryClass.create();
+      }
+      obj._entry._menu=obj;
+      obj._notItemElements=4;
+      // add entry to HTML element
+      obj._el.appendChild(obj._entry.element());
+
+      return obj;
+    },
+
+
+    /**
+     * Destroy this menu
+     * (in case you don't trust the
+     * mark and sweep GC)!
+     */
+    destroy : function () {
+       //based on menu.js
+      const t = this;
+
+      // Remove circular reference to "this" in menu
+      if (t._el != undefined)
+        delete t._el["menu"]; 
+
+      // Remove circular reference to "this" in items
+      t._items.forEach(function(i) {
+        delete i["_menu"];
+      });
+
+      // Remove circular reference to "this" in prefix
+      delete t._prefix['_menu'];
+      delete t._lengthField['_menu'];
+      delete t._slider['_menu'];
+      delete t._entry['_menu'];
+    },
+
+
+    // Arrow key and prefix treatment
+    _keydown : function (e) {
+      //based on menu.js
+      const t = this;
+
+      switch (_codeFromEvent(e)) {
+
+      case 27: // 'Esc'
+        e.halt();
+        t.hide();
+        break;
+
+      case 38: // 'Up'
+        e.halt();
+        t.prev();
+        break;
+
+      case 33: // 'Page up'
+        e.halt();
+        t.pageUp();
+        break;
+
+      case 40: // 'Down'
+        e.halt();
+        t.next();
+        break;
+
+      case 34: // 'Page down'
+        e.halt();
+        t.pageDown();
+        break;
+
+      case 39: // 'Right'
+        // "Use" this item
+        if (t._prefix.active())
+          break;
+
+        
+        else if (t._entry.active()){
+          break; 
+        }; 
+
+        const item = t.liveItem(t.position);
+        
+        if (item["further"] !== undefined) {
+          item["further"].bind(item).apply();
+        };
+        
+        e.halt();
+        break;
+
+      case 13: // 'Enter'
+        // Click on prefix
+        if (t._prefix.active())
+          t._prefix.onclick(e);
+        //Click on entry
+        else if (t._entry.active())
+          t._entry.onclick(e);
+        // Click on item
+        else
+          t.liveItem(t.position).onclick(e);
+        e.halt();
+        break;
+
+      case 8: // 'Backspace'
+        t._prefix.chop();
+        t._entry.chop();
+        t.show();
+        e.halt();
+        break;
+      };
+    },
+
+    // Add characters to prefix
+    _keypress : function (e) {
+      if (e.charCode !== 0) {
+        e.halt();
+        
+        // Add prefix
+        this._prefix.add(
+          String.fromCharCode(_codeFromEvent(e))
+        );
+        this._entry.add(
+          String.fromCharCode(_codeFromEvent(e))
+        );
+
+        this.show();
+      };
+    },
+
+    /**
+     * Filter the list and make it visible.
+     * This is always called once the prefix changes.
+     *
+     * @param {string} Prefix for filtering the list
+     */
+    show : function (active) {
+       //only two new lines compared to menu.js show method (see NEW LINE)
+      const t = this;
+
+      // show menu based on initial offset
+      t._unmark();     // Unmark everything that was marked before
+      t.removeItems();
+
+      // Initialize the list
+      if (!t._initList()) {
+
+        // The prefix is not active
+        t._prefix.active(true);
+        //FIRST NEW LINE
+        t._entry.active(false);
+
+        // finally show the element
+        t._el.classList.add('visible');
+        
+        return true;
+      };
+
+      let offset = 0;
+
+      // Set a chosen value to active and move the viewport
+      if (arguments.length === 1) {
+
+        // Normalize active value
+        if (active < 0) {
+          active = 0;
+        }
+        else if (active >= t.liveLength()) {
+          active = t.liveLength() - 1;
+        };
+
+        // Item is outside the first viewport
+        if (active >= t._limit) {
+          offset = active;
+          const newOffset = t.liveLength() - t._limit;
+          if (offset > newOffset) {
+            offset = newOffset;
+          };
+        };
+        
+        t.position = active;
+      }
+
+      // Choose the first item
+      else if (t._firstActive) {
+        t.position = 0;
+      }
+
+      // Choose no item
+      else {
+        t.position = -1;
+      };
+
+      t.offset = offset;
+      t._showItems(offset); // Show new item list
+
+      // Make chosen value active
+      if (t.position !== -1) {
+        t.liveItem(t.position).active(true);
+      };
+
+      // The prefix is not active
+      t._prefix.active(false);
+      //SECOND NEW LINE
+      t._entry.active(false);
+
+      // finally show the element
+      t._el.classList.add('visible');
+
+      // Add classes for rolling menus
+      t._boundary(true);
+
+      return true;
+    },
+
+    /**
+     * Hide the menu and call the onHide callback.
+     */
+    hide : function () {
+      if (!this.dontHide) {
+        this.removeItems();
+        this._prefix.clear();
+        this._entry.clear();
+        this.onHide();
+        this._el.classList.remove('visible');
+      }
+      // this._el.blur();
+    },
+
+
+    /**
+     * The alwaysEntry object
+     * the menu is attached to.
+     */ 
+    alwaysEntry : function () {
+      return this._entry;
+    },
+
+    /**
+   * Get/Set the alwaysEntry Text
+   */
+    alwaysEntryValue : function (value) {
+      if (arguments.length === 1) {
+        this._entry.value(value);
+        return this;
+      };
+      return this._entry.value();
+    },
+
+    /**
+     * Delete all visible items from the menu element
+     */
+
+    /**
+     * Make the next item in the filtered menu active
+     */
+    next : function () {
+      //Hohe zyklomatische Komplexität
+      const t = this;
+      // Activate prefix and entry
+      const prefix = this._prefix;
+      const entry = this._entry;
+
+      // No list
+      if (t.liveLength() === 0){ //switch between entry and prefix
+        if (!prefix.isSet()){//It is entry and it will stay entry
+          entry.active(true);
+          prefix.active(false);//Question: do we need to activate entry?
+          return; 
+        };
+        if (prefix.active() && !entry.active()){
+          t.position = 2; // ?
+          prefix.active(false);
+          entry.active(true); //activate entry
+          return;
+        }
+        else if (!prefix.active() && entry.active()){
+          t.position = 1; // ?
+          prefix.active(true); //activate prefix
+          entry.active(false);
+          return;
+        };
+        //otherwise: confusion
+        return;
+      };
+        
+      // liveLength!=0
+      // Deactivate old item
+      if (t.position !== -1 && !t._prefix.active() && !t._entry.active()) {
+        t.liveItem(t.position).active(false);
+      };
+
+      // Get new active item
+      t.position++;
+      let newItem = t.liveItem(t.position);
+
+      // The next element is undefined - roll to top or to prefix or to entry
+      if (newItem === undefined) {
+
+        if ( !entry.active() ){ //if entry is active we definetly go to first item next
+          if (prefix.isSet() && !prefix.active()){ //prefix is next and exists
+            t.position=t.liveLength()+1;
+            prefix.active(true); //activate prefix
+            entry.active(false);
+            return;
+          }
+          else if ( (prefix.isSet() && prefix.active()) || // we had prefix
+                    (!prefix.isSet() && !prefix.active()) ){ //or it isnt there
+            t.position=t.liveLength()+2; 
+            prefix.active(false);
+            entry.active(true); //activate entry
+            return;
+          };
+        }
+
+        // Choose first item
+        else {
+          newItem = t.liveItem(0);
+          // choose first item
+          t.position = 0;
+          t._showItems(0);
+          // we reach point A from here
+        };
+      }
+
+      // The next element is after the viewport - roll down
+      else if (t.position >= (t.limit() + t.offset)) {
+        t.screen(t.position - t.limit() + 1);
+      }
+
+      // The next element is before the viewport - roll up
+      else if (t.position <= t.offset) {
+        t.screen(t.position);
+      };
+
+      //Point A
+      t._prefix.active(false);
+      t._entry.active(false);
+      newItem.active(true);
+    },
+
+
+    /*
+     * Make the previous item in the menu active
+     */
+    prev : function () {
+      const t = this;
+      // Activate prefix and entry
+      const prefix = this._prefix;
+      const entry = this._entry;
+
+      // No list
+      if (t.liveLength() === 0){ //switch between entry and prefix
+        if (!prefix.isSet()){//It is entry and it will stay entry
+          entry.active(true);
+          prefix.active(false);//Question: do we need to activate entry?
+          return; 
+        };
+        
+        if (prefix.active() && !entry.active()){
+          t.position = 2; // ?
+          prefix.active(false);
+          entry.active(true); //activate entry
+          return;
+        }
+        else if (!prefix.active() && entry.active()){
+          t.position = 1; // ?
+          prefix.active(true); //activate prefix
+          entry.active(false);
+          return;
+        };
+        //otherwise: confusion
+      };
+
+      // Deactivate old item
+      if (!prefix.active() && !entry.active()) {
+
+        // No active element set
+        if (t.position === -1) {
+          t.position = t.liveLength();
+        }
+
+        // deactivate active element
+        else {
+          t.liveItem(t.position--).active(false); //returns before decrement
+        };
+      };
+
+      // Get new active item
+      let newItem = t.liveItem(t.position);
+
+      // The previous element is undefined - roll to bottom
+      if (newItem === undefined) {
+
+        
+        let offset =  t.liveLength() - t.limit();
+        
+        // Normalize offset
+        offset = offset < 0 ? 0 : offset;
+
+        // Choose the last item
+        t.position = t.liveLength() - 1;
+        
+        if(!entry.active()){
+          if (prefix.isSet() && prefix.active()){
+            // we were on prefix and now choose last item
+            newItem = t.liveItem(t.position);
+            t._showItems(offset);
+          }
+          else if(!prefix.active()){
+            // we need to loop around: pick entry
+            t.position=t.liveLength()+2; 
+            prefix.active(false);
+            entry.active(true); //activate entry
+            return;
+          };
+          //otherwise confusion
+        } else {
+          if(prefix.isSet()){ // we had entry and thus now need prefix
+            t.position=t.liveLength()+1;
+            prefix.active(true); //activate prefix
+            entry.active(false);
+            return;
+          } else { // we had entry but there is no prefix
+            newItem = t.liveItem(t.position);
+            t._showItems(offset); // Choose last item
+          };      
+        };
+      }
+
+      // The previous element is before the view - roll up
+      else if (t.position < t.offset) {
+        t.screen(t.position);
+      }
+
+      // The previous element is after the view - roll down
+      else if (t.position >= (t.limit() + t.offset)) {
+        t.screen(t.position - t.limit() + 2);
+      };
+
+      t._prefix.active(false);
+      t._entry.active(false);
+      newItem.active(true);
+    },
+// Append Items that should be shown
+_showItems : function (off) {
+  const t = this;
+
+  // optimization: scroll down one step
+  if (t.offset === (off - 1)) {
+    t.offset = off;
+
+    // Remove the HTML node from the first item
+    // leave lengthField/prefix/slider
+    t._el.removeChild(t._el.children[this._notItemElements]);
+
+    t._append(
+      t._list[t.offset + t.limit() - 1]
+    );
+  }
+
+  // optimization: scroll up one step
+  else if (t.offset === (off + 1)) {
+    t.offset = off;
+
+    // Remove the HTML node from the last item
+    t._el.removeChild(t._el.lastChild);
+
+    t._prepend(t._list[t.offset]);
+  }
+
+  else {
+    t.offset = off;
+
+    // Remove all items
+    t.removeItems();
+
+    // Use list
+    let shown = 0;
+
+    for (let i = 0; i < t._list.length; i++) {
+
+      // Don't show - it's before offset
+      shown++;
+      if (shown <= off)
+        continue;
+
+      t._append(t._list[i]);
+      
+      if (shown >= (t.limit() + off))
+        break;
+    };
+  };
+
+  // set the slider to the new offset
+  t._slider.offset(t.offset);
+},
+
+
+  };
+});
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index 01bf7d8..088618b 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -60,6 +60,7 @@
         params = {};
 
       const t = this;
+      t._notItemElements=3;
 
       t._itemClass = params["itemClass"] || defaultItemClass;
 
@@ -127,7 +128,7 @@
 
       t._limit = menuLimit;
       
-      t._items = new Array();
+      t._items = new Array(); //all childNodes, i.e. ItemClass, prefixClass
 
       // TODO:
       // Make this separate from _init
@@ -142,7 +143,7 @@
     readItems : function (list) {
       const t = this;
 
-      t._list = undefined;
+      t._list = undefined; //filtered List containing all itemClass items
 
       // Remove circular reference to "this" in items
       for (let i = 0; i < t._items.length; i++) {
@@ -179,6 +180,7 @@
     
     // Initialize the item list
     _initList : function () {
+      // Upon change also update alwaysmenu.js please
       const t = this;
 
       // Create a new list
@@ -258,6 +260,7 @@
      * mark and sweep GC)!
      */
     destroy : function () {
+      // Upon change also update alwaysmenu.js please
       const t = this;
 
       // Remove circular reference to "this" in menu
@@ -327,6 +330,7 @@
 
     // Arrow key and prefix treatment
     _keydown : function (e) {
+      //Upon change also update alwaysmenu.js please
       const t = this;
 
       switch (_codeFromEvent(e)) {
@@ -489,6 +493,7 @@
      * @param {string} Prefix for filtering the list
      */
     show : function (active) {
+      //Upon change please also update alwaysmenu.js (only two lines new there)
       const t = this;
 
       // show menu based on initial offset
@@ -623,6 +628,7 @@
         this._el.removeChild(liElements[0]);
       };
      },
+      
 
 
     /**
@@ -686,6 +692,7 @@
      * Make the next item in the filtered menu active
      */
     next : function () {
+      //Upon change please update alwaysmenu.js next
       const t = this;
 
       // No list
@@ -742,6 +749,7 @@
      * Make the previous item in the menu active
      */
     prev : function () {
+      //Upon Change please update alwaysmenu.js prev
       const t = this;
 
       // No list
@@ -870,7 +878,7 @@
 
         // Remove the HTML node from the first item
         // leave lengthField/prefix/slider
-        t._el.removeChild(t._el.children[3]);
+        t._el.removeChild(t._el.children[this._notItemElements]);
 
         t._append(
           t._list[t.offset + t.limit() - 1]
@@ -943,7 +951,7 @@
       // Append element after lengthField/prefix/slider
       e.insertBefore(
         item.element(),
-        e.children[3]
+        e.children[this._notItemElements]
       );
     }
   };
