本文介绍了jQuery'mmenu'打开时的回调事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jQuery mmenu插件在菜单完成打开后,我需要调用JavaScript函数.我从 API文档中看不到如何使用插件API来执行此操作,所以我也许唯一的选择就是观察<html>元素上的类名称,当打开菜单时,该类名称将获得mm-opened的类.但是,这感觉有点"hacky",所以我想知道是否有人可以在本机API的范围内看到完成所需的函数调用的方法?

Using the jQuery mmenu plugin I need to call a JavaScript function after the menu has finished opening. I can't see from the API documentation how to do this using the plug-in API, so I'm thinking perhaps the only option is to observe the class name on the <html> element, which gains a class of mm-opened when the menu is opened. This feels a little 'hacky' though, so I wondered if anyone could see a way, within the bounds of the native API, to accomplish the required function call?

与预期相反,openPanel事件在打开菜单时不会触发-仅在打开子菜单时才触发,因此尽管这表明它可以完成工作,但不会.

Contrary to expectations the openPanel event doesn't fire when the menu is opened - it only fires when sub-menus are opened, so although this suggests it would do the job, it doesn't.

非常感谢.

推荐答案

知道了(未记录!):

var api = $('#menu').data('mmenu');
api.bind('opened', function () {
    console.log('opened');
});

这篇关于jQuery'mmenu'打开时的回调事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 08:56