I'm trying to realize an modal popup with JSP, using Spring MVC.
In my index.jsp I have this href link:
<a href="findCompany" data-toggle="modal"data-target="#findCompany">Find company</a>
and, always in this .jsp, there is this code fragment:
<div class="modal fade" id="findCompany" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
When I click on find company href link, my @Controller redirects me in findCompany.jsp, where there is the form for find a company.
Here's the code of this .jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Azienda</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4><p>Cerca un'azienda <span class="glyphicon glyphicon-stats"></span></p></h4>
</div>
<div class="modal-body">
<form role="form" action="returnCompany">
<div class="form-group">
<input type="text" class="form-control" name="nomeAzienda" placeholder="Inserisci il nome" required>
</div>
</form>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-success">Cerca</button>
</div>
</div>
</body>
</html>
findCompany.jsp is shown like an modal popup, and that's is what I want.
Ok, everything works.
But, if I remove, from index.jsp, this one:
<div class="modal fade" id="findCompany" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
nothing works.
Why? I'm wrong something with the modal class.
I wish that this last code there wasn't. Just link in index.jsp and modal form in findCompany.jsp. It's possible? How to?
Sorry for bad english.
Thanks.