JQuery阻止我的导航栏下拉

时间:2017-05-04 20:08:10

标签: javascript jquery html jsp

我有一个.jsp文件,它使用这个脚本

<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>

在我的身体中,我将menu.html包含在我的.jsp文件中,如下所示:

<body>
    <jsp:include page="menu.html"/>
</body>

问题是,当我加入javascript时,我的菜单不再有效。通过&#34;不工作&#34;我的意思是,下拉菜单不再起作用了。为什么会这样?

针对home.jsp

<%@ page session="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="de">
    <head>
        <script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
    </head>
    <body>
        <jsp:include page="menu.html"/>
    </body>
</html>  

menu.html

<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">WORKS<span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="/link1">DOES NOT WORK</a></li>
            <li><a href="/link2">DOES NOT WORK</a></li>
            </ul>
        </li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

1 个答案:

答案 0 :(得分:1)

不确定你在做什么,但这似乎有效。也许是因为你错过了bootstrap.min.js文件?如果不是,请确保jquery.min.js文件位于所有bootstrap .js文件之前。

https://jsfiddle.net/64hbcvh9/1/

AFRKHTTPClient *client = [self getClient];

RKObjectManager *objectManager = [[RKObjectManager alloc] initWithHTTPClient:client];

RKObjectMapping *requestMapping = [RKObjectMapping mappingForClass:[NSNull class]];
[objectManager addRequestDescriptor:
 [RKRequestDescriptor requestDescriptorWithMapping:requestMapping
                                       objectClass:[NSNull class]
                                       rootKeyPath:nil
                                            method:RKRequestMethodAny]];

RKObjectMapping *responseMapping = [RKObjectMapping mappingForClass:[NSNull class]];
[objectManager addResponseDescriptor:
 [RKResponseDescriptor responseDescriptorWithMapping:responseMapping
                                              method:RKRequestMethodPOST
                                         pathPattern:nil
                                             keyPath:nil
                                         statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]];

 [objectManager postObject:@{} // <-- this works, but nil doesn't
                         path:@"/api/some/endpoint"
                   parameters:nil
                      success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
                          // succes code here
                      } failure:^(RKObjectRequestOperation *operation, NSError *error) {
                          // failure code here
                      }];