0

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;
    }
  }
}
lilasquared
  • 138
  • 1
  • 6
  • war u hav tried so far? –  Sep 07 '13 at 05:08
  • I was able to get it to work by adding onClick: { setLocationHref : false} in the mmenu options, and triggering the modal manualy via javascript. However this causes any other links I have in the menu to no longer work. – lilasquared Sep 07 '13 at 05:29
  • $("#modal-booking").modal("show"); u opening ur modal window by JS like this?? –  Sep 07 '13 at 05:42
  • Yep. That works fine, but setting the option in the mmenu causes other links to stop working – lilasquared Sep 07 '13 at 05:46
  • Have a look at the "one page scrolling" example in the download pack of the mmenu plugin. Behavior is basically the same except instead of opening a modal, it scrolls the page. – Fred Sep 07 '13 at 15:00

0 Answers0