MetisMenu could not be called more than once because it calls init()
function only once in its lifetime.
So it means if you are loading content of a element <div id="menu">
asynchronously using ajax and after that again binding event to <div id="menu">
by $('#menu').metisMenu();
won't make any difference.
So what you have to do is firstly destroy the existing metismenu event handler and then create a new one like below:
$('#menu').metisMenu('dispose'); //to stop and destroy metisMenu
$('#menu').metisMenu();
Below code is in angularjs
angular
.module('app', [])
.controller('menuCtrl', menuCtrl);
menuCtrl.$inject = ['$scope', '$http'];
function menuCtrl($scope, $http) {
var url = "http://localhost/api/menus";
$http.post(url)
.success(function (data, status, headers, config) {
// Destroy the existing metisMenu
angular.element("#menu").metisMenu('dispose');
//---- Update You div with data -----//
// Create new binding
angular.element("#menu").metisMenu();
})
.error(function (data, status, headers, config) {
console.log("Error");
});
}