You are here: Forums Ask a Rails expert RJS partial rendering...
Posted in Forums : Ask a Rails expert
Authority 0
Posting Rating 18
Sign in to rate this post
|
I’m having a problem with the RJS Partial rendering. Scenerio: Ajax link generator <%= link_to_remote "ProductSets", :url => "/categories/1/product_sets", :method => :get %> and the generated html/js is <a onclick="new Ajax.Request('/categories/1/product_sets', {asynchronous:true, evalScripts:true,
method:'get', parameters:'authenticity_token=' +
encodeURIComponent('164e6c54bbb20a0b544e80ad8aa694bfa65cafeb')});
return false;" href="#">ProductSets</a>
Since the request hits /categories/1/product_sets via method :get, the index action is invoked. page.replace_html :contentTop, :partial => 'list_product_sets', :collection => @product_sets When I click the ProductSets link, the div with ID contentTop is replaced with the response from the server. But the response is all javascripts.
try {
Element.update("contentTop", "\u003Cdiv class=\"innerConte .. ....
All the html contents of the partial _list_product_sets.html.erb is returned with encoded javascript codes. Can Anyone plz explaing me Whats wrong with the above code?? Thanks |
|
Authority 50
Posting Rating 90
Sign in to rate this post
|
Its seems to do right job, but incorrectly.. |
Authority 0
Posting Rating 18
Sign in to rate this post
|
@Alexey, |
Authority 50
Posting Rating 76
Sign in to rate this post
|
Are you sure you havent used the :update otion for link_to_remote ? The server response is okay, but what is done with it by the browser indicates that the JS returned by the server is used by Element.update instead of evaluated… Anyway, if you’ve chosen to go Alexey’s way then perhaps this would be even better: In your controller: Now you can get rid of the index.html.erb or index.rhtml file which only contained 1 line of code anyway… |
Ask a Rails expert : Send dynamicly generated pdf as attachement
Ask a Rails expert : Rails Google Maps Plugin
Ask a Rails expert : link_to_remote to empty a field
Ask a Rails expert : calling class method in before filter
Ask a Rails expert : Storing values in database from popupwindow form
Ask a Rails expert : Optimising code
Ask a Rails expert : File upload
Ask a Rails expert : Deployment Question
Ask a Rails expert : Prevent session dumps from search robots
Ask a Rails expert : Best way to protect contact form