Use the App.Menu
object to add custom options, alerts, and notices to the menu bar at the top of the page.
App.Menu.add(text, options_or_callback, callback)
Adds a menu option with the value of text
.
The second argument, options_or_callback
, is optional. If it's a function it'll be treated as the callback
and the third argument will be ignored. If it's an object, it can pass an id key to set the option element's ID.
The callback function is called when the option is clicked.
The function returns the option's ID as a string, generating a random one if a custom ID isn't set. Remove an option by passing its ID to the App.Menu.remove
function.
App.Menu.add("Option 1", function(event) {
console.log(e.target);
});
var id = App.Menu.add("Hey!", { id: "my_option" }, function() {
console.log("Hey")
});
console.log(id); // Outputs "my_option"
App.Menu.alert(text)
Adds an alert bar below the menu containing the text given. Alerts should be used to warn the user about errors or critical events.
App.Menu.alert("Warning!")
App.Menu.notice(text)
Adds a notice bar below the menu containing the text given. Notices should be used to tell the user about non-critical events.
App.Menu.alert("Your data has been saved.")
App.Menu.remove(id)
Removes a custom menu option by ID. If the "id" parameter is an integer, it'll remove the custom option at the given index.
navbar.remove("option_id")
navbar.remove(0) // Removes the first custom option