Render a partial file

Hi all…
Can we render a partial file while clicking on a link?

I tried the following:

<%= link_to_remote( “Cancel”,
:update => “edit_func_spec_div”,
:url => {:partial =>
‘cipart/show_functional_spec_to_edit’}
) %>

But it didn’t rendered the partial file specified.

Also i need to pass a variable to this partial file. How can i do this?

Please help

Thanks in advance
Regards
Suneeta

On 17 Mar 2008, at 11:15, Suneeta Km wrote:

               )  %>

You can do this, but not like that. The action you specify by the :url
hash can render any partial you fancy.

Fred

Frederick C. wrote:

On 17 Mar 2008, at 11:15, Suneeta Km wrote:

               )  %>

You can do this, but not like that. The action you specify by the :url
hash can render any partial you fancy.

Fred

Hi Fred…
Thanks for your reply

I changed my code like this:
<%= link_to_remote( “Cancel”,
:update => “edit_func_spec_div”,
:url => ‘cipart/show_functional_spec_to_edit’
) %>

But ‘no action found’ message generated.
cipart is not an action. It is a folder that contains all partial files
in my project.

So I changed the code as follows:
<%= link_to_remote( “Cancel”,
:update => “edit_func_spec_div”,
:url => ‘/cipart/show_functional_spec_to_edit’
) %>

Then routing error generated.

Please help to solve this.

Thanks
Suneeta

Suneeta Km wrote:

Hi all…
Can we render a partial file while clicking on a link?
I tried the following:
<%= link_to_remote( “Cancel”,
:update => “edit_func_spec_div”,
:url => {:partial =>
‘cipart/show_functional_spec_to_edit’}
) %>

<%= link_to_remote( “Cancel”,
:update => “edit_func_spec_div”,
:url => {:controller => ‘mycontroller’, :action =>
‘myaction’, :myvar => 100 }) %>

and then, in

Class MyController < …

def myaction
myvar = params[:myvar]
render :partial => ‘your/partial’, :locals => {:myvar => myvar }
end

end

hth

Shai R. wrote:

Suneeta Km wrote:

Hi all…
Can we render a partial file while clicking on a link?
I tried the following:
<%= link_to_remote( “Cancel”,
:update => “edit_func_spec_div”,
:url => {:partial =>
‘cipart/show_functional_spec_to_edit’}
) %>

<%= link_to_remote( “Cancel”,
:update => “edit_func_spec_div”,
:url => {:controller => ‘mycontroller’, :action =>
‘myaction’, :myvar => 100 }) %>

and then, in

Class MyController < …

def myaction
myvar = params[:myvar]
render :partial => ‘your/partial’, :locals => {:myvar => myvar }
end

end

hth

Hi…

Can’t we directly render a partial file in link_to_remote?

Thanks
Suneeta

On 17 Mar 2008, at 11:43, Suneeta Km wrote:

Hi…

Can’t we directly render a partial file in link_to_remote?

No you can’t. link_to_remote generates javascript to make a request to
your server. if you want that to render a partial then you need to
have an action on the other side that renders that partial.

Fred

Hi…
Is there any options other than link_to_remote for solving my problem?
Suneeta

if you didn’t want to use ajax, you could use javascript directly? You
could render the form on the page, hide it, then show it when you
click on your link. e.g:

<%= render :partial => "/cipart/show_functional_spec_to_edit" %>

<%= link_to_function “Cancel”, “$(‘my-hidden-form’).show()” %>

However that depends on how complex your hidden section will be… it
might not be appropriate.

On Mar 18, 1:16 am, Suneeta Km [email protected]

Frederick C. wrote:

On 17 Mar 2008, at 11:43, Suneeta Km wrote:

Hi…

Can’t we directly render a partial file in link_to_remote?

No you can’t. link_to_remote generates javascript to make a request to
your server. if you want that to render a partial then you need to
have an action on the other side that renders that partial.

Fred

Thanks Fred.
I have to implement this function in many places. I was trying to avoid
writing many actions for such a simple functionality.
So now i’m planning to write a single action and combine all by checking
conditions.
Thanks again
Suneeta