Hi, I believe it should be ok to leave the <link> and jQuery <script> in the header. This will be cached by the browser and you may well find yourself using it elsewhere too as it is quite useful.
Then for view-specific functions, there's no reason you can't place <script> into your view (index.html). It may not be the best way to make a reusable component, but if you're just worried about the index view, it's fine. If you get the behaviour you wish in that view, then you can consider how to make it more modular and accessible from other views. At that point you'll want to place it into layout or a common .js file. Pablo On Jul 29, 9:16 am, aure <[email protected]> wrote: > 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

