Hi everyone,
I would like that when a user clicks on a button "add an address", a
small window shows up with the form to be filled in. The point is that
I do not want to leave for another view to fill the form and then come
back, I want to stay on the page containing the button opening the
form... So I guess I would need some AJAX wouldn't I? But I am a real
newbie here...
How could I do that?
In my trial I thought I could use maybe a JQuery dialog for that.
So I have put this in layout.html within the <head> tag:
<link rel="stylesheet" type="text/css" href="http://
ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-
ui.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jqueryui/1.7.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var $dialog = $('<div></div>')
.html('This dialog will show every time!')
.dialog({
autoOpen: false,
title: 'Basic Dialog'
});
I thought I could use maybe a JQuery dialog for that.
$('#opener').click(function() {
$dialog.dialog('open');
// prevent the default action, e.g., following a link
return false;
});
});
</script>
Then I have put that in index.html:
<button id="opener">Open the dialog</button>
And it works all right. The dialog opens when I click the button,
but...
My first problem is : is there a way to define the <link> and <script>
tags in index.html instead of layout.html? Because I may only use
these scripts in index.html, but the problem is that the <head> is
defined in layout.html...
My second problem is: if I have to define <link> and <script> tags in
layout.html, how can I contextualise the html content of the dialog,
based on the view. Because I may want to use the dialog to display
information when called on a page1 but request to fill a form when
called on page2...
Any tip would be highly welcome :)
Thanks,
Aurelien