Is there a way to get a link to a partial to open in a div, which I can open with the prototype .toggle() ? What I want is to put a link on a page, which, when clicked, renders the partial in a div in that page. However, I dont want the partial merely sitting, already rendered in a hidden div, but rather, to be called and rendered when the link is hit (i.e. minimal transmission to the client) Is there a way I can do this? Thanks, RVince
You can''t do both of these things at the same time. If you want to use toggle, the content should already be there and may be hidden. If you want to generate the content when the link is clicked, then you should use link_to_remote to render the link, Then you can render a partial in your rjs template have something like this: page.replace_html, :partial => ''example'' On Aug 18, 3:46 am, RVince <rvinc...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> Is there a way to get a link to a partial to open in a div, which I > can open with > the prototype .toggle() ? > > What I want is to put a link on a page, which, when clicked, renders > the partial in a div in that page. However, I dont want the partial > merely sitting, already rendered in a hidden div, but rather, to be > called and rendered when the link is hit (i.e. minimal transmission to > the client) Is there a way I can do this? Thanks, RVince
So, say, in page a I have data in rows, say. On each row, a link. That link should open a form between the rows. YOu are saying there is a way I can do that with link_to_remote somehow On Aug 18, 10:55 am, hitch <larryhitc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You can''t do both of these things at the same time. > If you want to use toggle, the content should already be there and may > be hidden. > > If you want to generate the content when the link is clicked, then you > should use link_to_remote to render the link, > Then you can render a partial in your rjs template have something like > this: > page.replace_html, :partial => ''example'' > > On Aug 18, 3:46 am, RVince <rvinc...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: > > > Is there a way to get a link to a partial to open in a div, which I > > can open with > > the prototype .toggle() ? > > > What I want is to put a link on a page, which, when clicked, renders > > the partial in a div in that page. However, I dont want the partial > > merely sitting, already rendered in a hidden div, but rather, to be > > called and rendered when the link is hit (i.e. minimal transmission to > > the client) Is there a way I can do this? Thanks, RVince
Yes, link_to_remote will call some action in your controller. That action can generate javascript to update portion of your page. That controller can have an some-action.rjs template (instead of the usual some-action.html.erb) That template could look something like this: page.replace_html ''id-of-some-element-on-your-page'', :partial => ''partial you want to render there'' You could also render it directly in your controller if you prefer. Check out the following documentation: http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html#M001666 There are plenty of examples there. I might also recommend the peepcode screencast covering rjs. It walks through several simple examples. On Aug 18, 8:21 am, RVince <rvinc...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> So, say, in page a I have data in rows, say. On each row, a link. That > link should open a form between the rows. YOu are saying there is a > way I can do that with link_to_remote somehow > > On Aug 18, 10:55 am, hitch <larryhitc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > You can''t do both of these things at the same time. > > If you want to use toggle, the content should already be there and may > > be hidden. > > > If you want to generate the content when the link is clicked, then you > > should use link_to_remote to render the link, > > Then you can render a partial in your rjs template have something like > > this: > > page.replace_html, :partial => ''example'' > > > On Aug 18, 3:46 am, RVince <rvinc...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: > > > > Is there a way to get a link to a partial to open in a div, which I > > > can open with > > > the prototype .toggle() ? > > > > What I want is to put a link on a page, which, when clicked, renders > > > the partial in a div in that page. However, I dont want the partial > > > merely sitting, already rendered in a hidden div, but rather, to be > > > called and rendered when the link is hit (i.e. minimal transmission to > > > the client) Is there a way I can do this? Thanks, RVince