如何解决扩展zurb Foundation 5 JavaScript插件
对于一个非常老的客户项目,我想为网站扩展Foundation 5的javascript插件顶部栏的events方法。我通过npm拉Foundation-sites@5.5.3。 foundation5在jquery@2.2.4上运行。 插件看起来像这样:
;(function ($,window,document,undefined) {
'use strict';
Foundation.libs.topbar = {
name : 'topbar',version : '5.5.3',settings : {
index : 0,start_offset : 0,sticky_class : 'sticky',custom_back_text : true,back_text : 'Back',mobile_show_parent_link : true,is_hover : true,scrolltop : true,// jump to top when sticky nav menu toggle is clicked
sticky_on : 'all',dropdown_autoclose: true
},init : function (section,method,options) {
Foundation.inherit(this,'add_custom_rule register_media throttle');
var self = this;
self.register_media('topbar','foundation-mq-topbar');
...
},events: {...}
...
};
}(jQuery,window.document));
现在我想重写events方法以更改事件回调之一的行为。因此,当我的用户单击选择框以选择某项时,顶部栏菜单下拉列表保持打开状态。标准行为是单击下拉菜单中的一项=关闭下拉菜单。
.on('click.fndtn.topbar','[' + this.attr_name() + '] .has-dropdown>a',function (e) {...}
要解决此问题,我需要插入一张额外的支票
if(li.hasClass('hover') && !settings.dropdown_autoclose) {
return;
}
我现在想做的是这样的:
/* Third party libs */
<script src="../../node_modules/jquery2/dist/jquery.min.js">
<script src="../../node_modules/foundation-sites-5/js/foundation.js">
/* customizing */
<script src="./js/foundation_customizing.js">
<script type="text/javascript">
$(document).foundation();
</script>
我现在对jquery对待插件的了解不多。因此,我在尝试访问Foundation.libs.topbar.events
时花了些时间,但似乎无法通过window对象直接访问。
所以请帮帮我。我该如何以jquery的方式覆盖该方法?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。