How do I link to a Bootstrap Modal using jQuery mmenu?

652 Views Asked by At

I am using the jQuery mmenu plugin to develop a mobile site in conjunction with the twitter boostrap 3.0 CSS framework. I was wondering if there is a way to use the mmenu to link to a modal pop up. The current behavior I am seeing is that the mmenu closes, and then the page attempts to go to the URL of the modal ID which is used as the href parameter in the link that should toggle the menu. Perhaps I am mistaken but I believe that javascript handles the modal pop up and the mmenu javascript might be getting in the way of that. If anyone has any advice that would be great! Thanks!

edit: I was able solve the problem by passing the mmenu this callback function onClick, however I am interested to know if there is a cleaner way to do it.

onClick : {
  setLocationHref : false,
  callback : function()
  {
    var href = $(this).attr('href');
    if (href.match(/#modal-/)) {
      $(href).modal('toggle');
    } else {
      window.location = href;
    }
  }
}
0

There are 0 best solutions below