基础6手风琴菜单 - 持久状态

时间:2016-03-09 22:38:22

标签: accordion zurb-foundation-6

当用户导航到该子菜单中的链接时,我正试图让子菜单保持打开状态。在我的搜索中,我发现此代码检查当前URL是否与任何href匹配,如果是,则切换该类(我收集)。但是,我无法使用我认为我想要合并的内容,即Foundation API。

保留Foundation 6手风琴菜单项状态的最佳方法是什么?

这是我到目前为止所做的:

2016-03-09 23:07:09.176 ERROR 29740 --- [nio-8080-exec-7] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-8080-exec-7] Exception processing template "createAccommodation": Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputCheckboxFieldAttrProcessor' (createAccommodation:73)
2016-03-09 23:07:09.183 ERROR 29740 --- [nio-8080-exec-7] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringInputCheckboxFieldAttrProcessor' (createAccommodation:73)] with root cause

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'types' available as request attribute
    at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:144)
    at org.thymeleaf.spring4.util.FieldUtils.getBindStatusFromParsedExpression(FieldUtils.java:396)
    at org.thymeleaf.spring4.util.FieldUtils.getBindStatus(FieldUtils.java:323)
    at org.thymeleaf.spring4.util.FieldUtils.getBindStatus(FieldUtils.java:289)
.....

1 个答案:

答案 0 :(得分:1)

您需要将子菜单('ul')传递给函数'down',因为您使用链接'a','ul'是她'li'(parent()的父级。 parent()),你想要显示'ul'子菜单。

    $('.main-nav a').each(function(){
         var myHref= $(this).attr('href');
         var pathname = window.location.pathname;
         if(pathname.match(myHref)) {
           $('.menu').foundation('down', $(this).parent().parent());
         }
    });
相关问题