Difei Zhao wrote:
> Starr Horne wrote:
>> On Tue, 3 Mar 2009 20:25:58 -0600
>> Greg Donald <[email protected]> wrote:
>> 
>>> > allowed you to render partials in the .rjs file and execute the
>>> > javascript which updates the page, how can I do that using jquery?
>>> > Thanks in advance!
>> 
>> 
>> I have successfully used the jRails plugin. You just drop it in and it 
>> changes the built in JS jelpers to use jquery. 
>> http://ennerchi.com/projects/jrails
>> 
>> 
>> --
>> Starr Horne
>> My blog: http://starrhorne.com
>> Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/
> 
> Hi, since I'd like write js code by hand with jquery, so "render 
> :partial" in .js.erb file just fills my needs.


for newbies like me who don't want to use jrails in rails 3 and might 
need it spelled out, rather than:

render :update do |page|
  page.replace_html 'preview', :partial => 'preview'
end

do something like this in your controller:

render :action => :preview

and in your preview.js.erb file do something like:

jQuery('#preview').html('<%= javascript_escape(render(:partial => 
"preview")) %>');

of course, you'd also need a partial named _preview.erb (or 
_preview.haml)

good luck!
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to