A modal window is generally done using javascript. For example, using jQuery UI (from the docs)
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#dialog" ).dialog();
});
</script>
</head>
<body>
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
</body>
</html>
Sinatra/Padrino will take care of the layout and the view, you just have to add the script portion. Assuming you're using Haml, your view would look like this:
#dialog{title: "Basic dialog"}
%p
This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.
:javascript
$(function() {
$( "#dialog" ).dialog();
});
The javascript doesn't need to go inside the head
tags as the jQuery docs suggest.
Edit:
There are a couple of choices for loading a partial into a window. One is to use a javascript library like Handlebars, but I prefer to get the javascript to load it from a route, that way all the view code stays together, e.g.
get "/templates/modal1/?" do
haml :modal1, :layout => !xhr?
end
In the javascript, make an AJAX call to that route and you'll get only the HTML sans the layout, then use it to fill the box:
$.get('ajax/test.html', function(data) {
$('#dialog').html(data);
}
and in your view just describe the div:
#dialog1
-# The HTML from the view will be put here by the jQuery code.
Something like that.