Search Results

Search found 64 results on 3 pages for 'rjs'.

Page 1/3 | 1 2 3  | Next Page >

  • Updating multiple divs w/ RJS/AJAX

    - by bgadoci
    I am successfully using RJS to implement AJAX on a page.replace.html create.js.rjs. I am attempting to update two locations instead of one and after watching Ryan Bates Railscast I am very close (I think) but have a problem in the syntax of my /views/likes/create.js.rjs file. Here is the situation: located at /views/likes/create.js.rjs is the following code: page.replace_html "votes_#{ @site.id }", :partial => @like page.replace_html "counter", 10 - (@question.likes.count :conditions => {:user_id => current_user.id}) page[@like].visual_effect :highlight My problem lies in the second line. The div "counter" displays the following code in the /views/question/show.html.erb page: <div id="counter"> You have <%= 10 - (@question.likes.count :conditions => {:user_id => current_user.id}) %> votes remaining for this question </div> From watching the screen cast I believe that my error has to do w/ the syntax of the second line. Specifically he mentions that you cannot use a local instance variable but not sure how to make the change. Thoughts?

    Read the article

  • adding visual effects to RJS before action rendered

    - by Sam
    I just started using RJS which is awesome however I am used to putting visual effects in the link_to_remote and such and I'm not sure how to trigger actions before and after remotes are triggered. Take this link for example: HTML <span id="<%= "edit_comment_link_#{comment.id.to_s}"%>" style="float:left;"> <%= link_to_remote "edit", {:update => "comment_#{comment.id.to_s}", :url => edit_post_comment_path(comment.post, comment), :method => :get}%> | </span> Controller: def edit @comment = Comment.find(params[:id]) respond_to do |format| #format.html render edit_comment_path(@comment) format.js end end RJS: page.replace_html "edit_comment_link_#{@comment.id.to_s}", "currently editing | " So is RJS mainly for after actions are rendered visual effects such as a spinner should be put into the link_to_remote with call_backs? Is this a good way of doing things?

    Read the article

  • Creating records using RJS in rails

    - by Elliot
    Hey Everyone, so I've watched http://railscasts.com/episodes/43-ajax-with-rjs but I have a question: In my view I have the following: <div id="testly"> <%= render :partial => "test" %> </div> This works. Using create.rjs to change the content in this div, I have the following in my create.rjs file: page.replace_html :testly, :partial = 'test' Simply put, this should just refresh the partial right? But its not working... Would love any suggestions!

    Read the article

  • rails rjs modify style in the body to add margin

    - by holden
    How can I use RJS to modify CSS elements on a page? I'm looking to do modify the margin of a div to add a "margin-top: 2.8em;" How can I access this with RJS or should i use something like page << "document.getElementById('super-wrap').style.margin-top='2.8em;';" Though this doesn't work. Thanks

    Read the article

  • Page replace with RJS

    - by Jiang
    Hi all, I try to implement a vote feature in one of my rails projects. I use the following codes (in vote.rjs) to replace the page with a Partial template (_vote.rhtml). But when I click, the vote number can not be updated immediately. I have to refresh the page to see the change. vote.rjs page.replace("votes#{@foundphoto.id}", :partial="vote", :locals={:voteable=@foundphoto}) The partial template is as follows: _vote.rhtml " <%= link_to_remote "+(#{voteable.votes_for})", :update="vote", :url = { :action="vote", :id=voteable.id, :vote="for"} % / <%= link_to_remote "-(#{voteable.votes_against})", :update="vote", :url = { :action="vote", :id=voteable.id, :vote="against"} % any ideas? Thanks.

    Read the article

  • Problem with displaying content when using RJS

    - by Shreyas Satish
    I'm quite sure this is a silly error but I'm unable to spot it. Please help me out on this. This is my controller code def filter_by_content @articles = Article.find(:all) end My RJS (filter_by_content.rjs) update_page do |page| page.replace_html 'articles', :partial => 'main/filtered', :object => @articles end My Partial 'filtered' <div id = "articles"> <% if @articles %> <% @articles.each do |article| %> <%= article.title %> <% end %> <% end %> </div> I checked my server, and the articles are sure getting fetched but the problem is with displaying them. Thanks !

    Read the article

  • Rails RJS template displays code instead of the html page

    - by Anand
    After having Googled and hurting my brain for hours on this, I finally decided to post this question. Here's the code... view1.html.erb -------------- <%=link_to_remote_redbox "Link", :url => {:action => :action1, :id => @some.id} some_controller.rb ------------------ def action1 render :layout => false end def action2 do some processing end action1.html.erb -------------------- <form onsubmit="new Ajax.Request('/some_controller/action2', {asynchronous:true, evalScripts:true, onComplete:function(request){RedBox.close(); return false;}, parameters:Form.serialize(this)}); return false;}" method="post" action="/some_controller/action2"> <input type=text name='username'> <input type='submit' value='submit'> </form> action2.rjs ----------- page.replace_html("some_div", (render(:partial => "some_partial"))) with that code in place when action2.rjs kicks in it should display the html page instead I am getting this Element.update("some_div", "<style type=\"text/css\">\n\n.............. As suggested on other posts I read, they say its caused because of the ":update = some_div" in the link_to_remote_redbox function but clearly my code doesn't have that. Help is always appreciated. Many Thanks

    Read the article

  • Rails 3 and RJS

    - by Denis
    Hi, I use the rails 3.0.0.beta Is there any new syntax to write RJS, here is an example def remote_create @photo = Photo.new(params[:photo]) respond_to do |format| if @photo.save # add @photo's thumbnail to last import tag format.js { render :update do |page| page.insert_html :bottom, 'polaroids' , :partial => 'polaroid', :locals => {:photo => @photo} end } else #... end end end

    Read the article

  • Ruby 'if' condition in rjs

    - by ash34
    Hi, I want to insert a user in the userlist only if the user object (@row) is not nil. How do I do the insert conditionally in an rjs template? page.insert_html :bottom, :userlist, render(:partial = "user", :locals = { :user = @row, :myid = @row.id }) thanks much.

    Read the article

  • RJS in controller

    - by Jamal Abdul Nasir
    i have put the following rjs in a controller... but it gives me the following error... TypeError: Element.update is not a function respond_to do |format| format.js do responds_to_parent do render :update do |page| page.replace_html 'errorLay', :text => "Page with the same name already exists." page.show 'errorLay' page.delay(2) do page.hide 'errorLay' end end end end end so how can i get rid of this error...?

    Read the article

  • RJS error: TypeError: element is null

    - by salilgaikwad
    Hi All, I got RJS error: TypeError: element is null while using ajax. I used in view <%= periodically_call_remote(:url={:action='get_user_list', :id='1'}, :frequency = '5') % in controller render :update do |page| page.replace_html 'chat_area', :partial => 'chat_area', :object = [@chats, @user] if @js_update end in partial chat_area <% if [email protected]? && !show_div(@chats).blank?% <% show_div_id=show_div(@chats) % <% for chat in @chats % " style="display:<%= (chat.id == show_div_id)? 'block' : 'none' %;" <% form_remote_for(:chat, :url => {:controller=>'chats', :action='create', :id=1}, :html={:name = "form_#{chat.id}"}, :complete="resetContent('#{chat.id}');") do |f| % <%= f.hidden_field :sessionNo, :value=chat.sessionNo % <%= f.text_area :chatContent, :id= "chatContent_field_#{chat.id}", :cols="100", :rows="6", :onKeyPress="return submitenter(this,event);" % ')"/ <% end % </div> <% end % <% else % <% end % My div present in index.html.erb <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tbody><tr> <td align="left" width="80%" valign="top" style=""> <%= text_area :chat, :chatContent, :id=> "chatContent_field", :cols=>"100", :rows=>"6" %> </td> <td align="left" width="20%" valign="bottom" style="padding-left:10px;padding-left:10px;x" > <div id="chat_area"> <%= render :partial => 'chat_area' %> </div> </td> </tr> </tbody> </table> Any help is appreciated. Regards, Salil Gaikwad

    Read the article

  • confusion using rjs for a link_to_remote

    - by odpogn
    My application layout contains a navigation div, and a content div constructed as a partial. I want to use ajax so that whenever a person clicks on a link in the navigation div, the contents of that page renders in the content div without a refresh. I'm confused on how to properly do this... any help for a rails noob??? thanks in advance~ application.html.erb <body> <div id="container"> <%= render 'layouts/header' %> <%= render 'layouts/content'%> <%= render 'layouts/footer' %> </div> </body> _header.html.erb <%= link_to_remote "Home", :url => { :controller => "pages", :action => "home" } %> _content.html.erb <div id="content"> <%= yield %> </div> pages_controller.rb def home @title = "Home" respond_to do |format| format.js end end home.rjs page.replace_html :container, :partial => 'layouts/content'

    Read the article

  • Sortable_element with RJS does not working

    - by jaycode
    I have a list of images where user can arrange their orders. When user uploaded an image, I want the list to still be sortable. I am using a similar upload that was described here: http://kpumuk.info/ruby-on-rails/in-place-file-upload-with-ruby-on-rails/ Please help. Here are the code for upload in view file: <% form_for [:admin, @new_image], :html => { :target => 'upload_frame', :multipart => true } do |f| %> <%= hidden_field_tag :update, 'product_images'%> <%= f.hidden_field :image_owner_id %> <%= f.hidden_field :image_owner_type %> <%= f.file_field :image_file %><br /> or get image from this URL: <%= f.text_field :image_file_url %> <%= f.hidden_field :image_file_temp %><br /> <%= f.submit "Upload Image" %> <% end %> And in controller view: def create @image = Image.new(params[:image]) logger.debug "params are #{params.inspect}" if @image.save logger.debug "initiating javascript now" responds_to_parent do render :update do |page| logger.debug "javascript test #{sortable_element("product_images", :url => sort_admin_images_path, :handle => "handle", :constraint => false)}" page << "show_notification('Image Uploaded');" page.replace_html params[:update], :partial => '/admin/shared/editor/images', :locals => {:object => @image.image_owner, :updated_image => @image} page << sortable_element("product_images", :url => sort_admin_images_path, :handle => "handle", :constraint => false) end end #render :partial => '/admin/shared/editor/images', :locals => {:object => @image.image_owner, :updated_image => @image} else responds_to_parent do render :update do |page| page << "show_notification('Image Upload Error');" end end end end Or, to rephrase the question: Running this: page.replace_html params[:update], :partial => '/admin/shared/editor/images', :locals => {:object => @image.image_owner, :updated_image => @image} page << sortable_element("product_images", :url => sort_admin_images_path, :handle => "handle", :constraint => false) Will NOT adding sortable list feature. Please help, Thank you

    Read the article

  • Can Ruby on Rails handle AJAX Response by Static Javascript code? by using RJS?

    - by Jian Lin
    So it looks like on RoR, when Ajax (using form_remote_tag) returns a success code, Javascript is also returned to handle the visual effects. (this is the RJS mechanism) using Fiddler, I do see the following response: try { Element.update("vote_score", "Score 58"); $("vote_score").visualEffect("highlight"); } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.update(\"vote_score\", \"Score 58\");\n$(\"vote_score\").visualEffect(\"highlight\");'); throw e } Will there be situation where the code is quite big (like 1 or 2k) that RJS can use some sort of static Javascript already loaded to handle the effect? Is there any other ways to use static Javascript already loaded with the page? Must it be just raw Javascript and use the Prototype's Ajax success response to call the static Javascript code, or can it be some Rails mechanism related to RJS?

    Read the article

  • Using RJS to replace innerHTML with a real live instance variable.

    - by Steve Cotner
    I can't for the life of me get RJS to replace an element's innerHTML with an instance variable's attribute, i.e. something like @thing.name I'll show all the code (simplified from the actual project, but still complete), and I hope the solution will be forehead-slap obvious to someone... In RoR, I've made a simple page displaying a random Chinese character. This is a Word object with attributes chinese and english. Clicking on a link titled "What is this?" reveals the english attribute using RJS. Currently, it also hides the "What is this?" link and reveals a "Try Another?" link that just reloads the page, effectively starting over with a new random character. This is fine, but there are other elements on the page that make their own database queries, so I would like to load a new random character by an AJAX call, leaving the rest of the page alone. This has turned out to be harder than I expected: I have no trouble replacing the html using link_remote_to and page.replace_html, but I can't get it to display anything that includes an instance variable. I have a Word resource and a Page resource, which has a home page, where all this fun takes place. In the PagesController, I've made a couple ways to get random words. Either one works fine... Here's the code: class PagesController < ApplicationController def home all_words = Word.find(:all) @random_word = all_words.rand @random_words = Word.find(:all, :limit => 100, :order => 'rand()') @random_first = @random_words[1] end end As an aside, the SQL call with :limit => 100 is just in case I think of some way to cycle through those random words. Right now it's not useful. Also, the 'rand()' is MySQL specific, as far as I know. In the home page view (it's HAML), I have this: #character_box = render(:partial => "character", :object => @random_word) if @random_word #whatisthis = link_to_remote "? what is this?", :url => { :controller => 'words', :action => 'reveal_character' }, :html => { :title => "Click for the translation." } #tryanother.{:style => "display:none"} = link_to "try another?", root_path Note that the #'s in this case represent divs (with the given ids), not comments, because this is HAML. The "character" partial looks like this (it's erb, for no real reason): <div id="character"> <%= "#{@random_word.chinese}" } %> </div> <div id="revealed" style="display:none"> <ul> <li><span id="english"><%= "#{@random_word.english_name}" %></span></li> </ul> </div> The reveal_character.rjs file looks like this: page[:revealed].visual_effect :slide_down, :duration => '.2' page[:english].visual_effect :highlight, :startcolor => "#ffff00", :endcolor => "#ffffff", :duration => '2.5' page.delay(0.8) do page[:whatisthis].visual_effect :fade, :duration => '.3' page[:tryanother].visual_effect :appear end That all works perfectly fine. But if I try to turn link_to "try another?" into link_to_remote, and point it to an RJS template that replaces the "character" element with something new, it only works when I replace the innerHTML with static text. If I try to pass an instance variable in there, it never works. For instance, let's say I've defined a second random word under Pages#home... I'll add @random_second = @random_words[2] there. Then, in the home page view, I'll replace the "try another?" link (previously pointing to the root_path), with this: = link_to_remote "try another?", :url => { :controller => 'words', :action => 'second_character' }, :html => { :title => "Click for a new character." } I'll make that new RJS template, at app/views/words/second_character.rjs, and a simple test like this shows that it's working: page.replace_html("character", "hi") But if I change it to this: page.replace_html("character", "#{@random_second.english}") I get an error saying I fed it a nil object: ActionView::TemplateError (undefined method `english_name' for nil:NilClass) on line #1 of app/views/words/second_character.rjs: 1: page.replace_html("character", "#{@random_second.english}") Of course, actually instantiating @random_second, @random_third and so on ad infinitum would be ridiculous in a real app (I would eventually figure out some better way to keep grabbing a new random record without reloading the page), but the point is that I don't know how to get any instance variable to work here. This is not even approaching my ideal solution of rendering a partial that includes the object I specify, like this: page.replace_html 'character', :partial => 'new_character', :object => @random_second As I can't get an instance variable to work directly, I obviously cannot get it to work via a partial. I have tried various things like: :object => @random_second or :locals => { :random_second => @random_second } I've tried adding these all over the place -- in the link_to_remote options most obviously -- and studying what gets passed in the parameters, but to no avail. It's at this point that I realize I don't know what I'm doing. This is my first question here. I erred on the side of providing all necessary code, rather than being brief. Any help would be greatly appreciated.

    Read the article

  • How do I find the object with the oldest updated_at column in RJS?

    - by user284194
    Hello, I'm trying to remove the object with the oldest updated_at value when the rjs is executed. page.insert_html :top, :messages, :partial => @message page[@message].visual_effect :grow page[:message_form].reset Message.old_messages.each do |m| page.remove(m.id) end page.delay(1) do page.select('.message').last.visual_effect :fade end I'm using .last in there right now, but I have a periodically_call_remote in the view that continually updates and runs the rjs above. The line: page.select('.message').last.visual_effect :fade seems to only execute the first time because after the message that is "last" fades away there's nothing recognized as "last" anymore so I figure instead of calling .last I could find the object that has the oldest updated_at time stamp and just remove that instead. I'm thinking that I probably cannot do this using page.select since it only calls on css elements. And therefore I probably don't have access to the updated_at values in the Message model. Does anyone have a suggestion on how to accomplish removing the oldest message with rjs? The messages are already automatically removed in the model as new messages are created. But I want them to fade automatically when the RJS refreshes the element.

    Read the article

  • Destroying a record via RJS TemplateError (Called ID for nil...)

    - by bgadoci
    I am trying to destroy a record in my table via RJS and having some trouble. I have successfully implemented this before so can't quite understand what is not working here. Here is the setup: I am trying to allow a user of my app to select an answer from another user as the 'winning' answer to their question. Much like StackOverflow does. I am calling this selected answer 'winner'. class Winner < ActiveRecord::Base belongs_to :site belongs_to :user belongs_to :question validates_uniqueness_of :user_id, :scope => [:question_id] end I'll spare you the reverse has_many associations but I believe they are correct (I am using has_many with the validation as I might want to allow for multiple later). Also, think of site like an answer to the question. My link calling the destroy action of the WinnersController is located in the /views/winners/_winner.html.erb and has the following code: <% div_for winner do %> Selected <br/> <%=link_to_remote "Destroy", :url => winner, :method => :delete %> <% end %> This partial is being called by another partial `/views/sites/_site.html.erb and is located in this code block: <% if site.winners.blank? %> <% remote_form_for [site, Winner.new] do |f| %> <%= f.hidden_field :question_id, :value => @question.id %> <%= f.hidden_field :winner, :value => "1" %> <%= submit_tag "Select This Answer" %> Make sure you unselect any previously selected answers. <% end %> <% else %> <div id="winner_<%= site.id %>" class="votes"> <%= render :partial => site.winners%> </div> <% end %> <div id="winner_<%= site.id %>" class="votes"> </div> And the /views/sites/_site.html.erb partial is being called in the /views/questions/show.html.erb file. My WinnersController#destroy action is the following: def destroy @winner = Winner.find(params[:id]) @winner.destroy respond_to do |format| format.html { redirect_to Question.find(params[:post_id]) } format.js end end And my /views/winners/destroy.js.rjs code is the following: page[dom_id(@winner)].visual_effect :fade I am getting the following error and not really sure where I am going wrong: Processing WinnersController#destroy (for 127.0.0.1 at 2010-05-30 16:05:48) [DELETE] Parameters: {"authenticity_token"=>"nn1Wwr2PZiS2jLgCZQDLidkntwbGzayEoHWwR087AfE=", "id"=>"24", "_"=>""} Rendering winners/destroy ActionView::TemplateError (Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id) on line #1 of app/views/winners/destroy.js.rjs: 1: page[dom_id(@winner)].visual_effect :fade app/views/winners/destroy.js.rjs:1:in `_run_rjs_app47views47winners47destroy46js46rjs' app/views/winners/destroy.js.rjs:1:in `_run_rjs_app47views47winners47destroy46js46rjs' Rendered rescues/_trace (137.1ms) Rendered rescues/_request_and_response (0.3ms) Rendering rescues/layout (internal_server_error)

    Read the article

  • What is the right way to make a new XMLHttpRequest from an RJS response in Ruby on Rails?

    - by Yuri Baranov
    I'm trying to come closer to a solution for the problem of my previous question. The scheme I would like to try is following: User requests an action from RoR controller. Action makes some database queries, makes some calculations, sets some session variable(s) and returns some RJS code as the response. This code could either update a progress bar and make another ajax request. display the final result (e.g. a chart grahic) if all the processing is finished The browser evaluates the javascript representation of the RJS. It may make another (recursive? Is recursion allowed at all?) request, or just display the result for the user. So, my question this time is: how can I embed a XMLHttpRequest call into rjs code properly? Some things I'd like to know are: Should I create a new thread to avoid stack overflow. What rails helpers (if any) should I use? Have anybody ever done something similar before on Rails or with other frameworks? Is my idea sane?

    Read the article

  • How to disable Rails submit buttons alongside Prototype helpers & RJS?

    - by Jesse
    I'm trying to follow this post http://stackoverflow.com/questions/576240/how-can-i-unobtrusively-disable-submit-buttons-with-javascript-and-prototype but I can't get it to work. The form triggers an RJS function, so I need to keep the helpers' onclick events intact. The RJS returns/reloads the same forms along with two new texts. I'm really confused. Here is my rails code for the forms: .span-20#comparison / new comparison . . . / voting forms (also reloaded) .span-4.prepend-3.append-6 - form_remote_tag :action => url_for(:controller => :comparisons), :method => :post do = hidden_field_tag :poem1_id, poems[:a].id = hidden_field_tag :poem2_id, poems[:b].id = hidden_field_tag :response, 1 = submit_tag "Vote for me", :disabled => false, :disable_with => 'Vote for me', :class => "compare" .span-4.append-3.last - form_remote_tag :action => url_for(:controller => :comparisons), :method => :post do = hidden_field_tag :poem1_id, poems[:a].id = hidden_field_tag :poem2_id, poems[:b].id = hidden_field_tag :response, 2 = submit_tag "Vote for me", :disable_with => 'Vote for me', :class => "compare" .span-4.prepend-8.append-8.prepend-top.last - form_remote_tag :action => url_for(:controller => :comparisons), :method => :post do = hidden_field_tag :poem1_id, poems[:a].id = hidden_field_tag :poem2_id, poems[:b].id = hidden_field_tag :response, 'draw' = submit_tag "Declare Draw", :disable_with => 'Declare Draw', :class => "compare" RJS page.replace_html :comparison, :partial => 'poems', :object => @poems page.insert_html :top, :previous, :partial => 'comparison', :object => @comparison page << "Effect.ScrollTo($('top'));"

    Read the article

  • How do disable Rails submit buttons alongside Prototype helpers & RJS?

    - by Jesse
    I'm trying to follow this post http://stackoverflow.com/questions/576240/how-can-i-unobtrusively-disable-submit-buttons-with-javascript-and-prototype but I can't get it to work. The form triggers an RJS function, so I need to keep the helpers' onclick events intact. The RJS returns/reloads the same forms along with two new texts. I'm really confused. Here is my rails code for the forms: .span-20#comparison / new comparison . . . / voting forms (also reloaded) .span-4.prepend-3.append-6 - form_remote_tag :action => url_for(:controller => :comparisons), :method => :post do = hidden_field_tag :poem1_id, poems[:a].id = hidden_field_tag :poem2_id, poems[:b].id = hidden_field_tag :response, 1 = submit_tag "Vote for me", :disabled => false, :disable_with => 'Vote for me', :class => "compare" .span-4.append-3.last - form_remote_tag :action => url_for(:controller => :comparisons), :method => :post do = hidden_field_tag :poem1_id, poems[:a].id = hidden_field_tag :poem2_id, poems[:b].id = hidden_field_tag :response, 2 = submit_tag "Vote for me", :disable_with => 'Vote for me', :class => "compare" .span-4.prepend-8.append-8.prepend-top.last - form_remote_tag :action => url_for(:controller => :comparisons), :method => :post do = hidden_field_tag :poem1_id, poems[:a].id = hidden_field_tag :poem2_id, poems[:b].id = hidden_field_tag :response, 'draw' = submit_tag "Declare Draw", :disable_with => 'Declare Draw', :class => "compare" RJS page.replace_html :comparison, :partial => 'poems', :object => @poems page.insert_html :top, :previous, :partial => 'comparison', :object => @comparison page << "Effect.ScrollTo($('top'));"

    Read the article

  • Ajax request gets to server but page doesn't update - Rails, jQuery

    - by Jesse
    So I have a scenario where my jQuery ajax request is hitting the server, but the page won't update. I'm stumped... Here's the ajax request: $.ajax({ type: 'GET', url: '/jsrender', data: "id=" + $.fragment().nav.replace("_link", "") }); Watching the rails logs, I get the following: Processing ProductsController#jsrender (for 127.0.0.1 at 2010-03-17 23:07:35) [GET] Parameters: {"action"=>"jsrender", "id"=>"products", "controller"=>"products"} ... Rendering products/jsrender.rjs Completed in 651ms (View: 608, DB: 17) | 200 OK [http://localhost/jsrender?id=products] So, it seems apparent to me that the ajax request is getting to the server. The code in the jsrender method is being executed, but the code in the jsrender.rjs doesn't fire. Here's the method, jsrender: def jsrender @currentview = "shared/#{params[:id]}" respond_to do |format| format.js {render :template => 'products/jsrender.rjs'} end end For the sake of argument, the code in jsrender.rjs is: page<<"alert('this works!');" Why is this? I see in the params that there is no authenticity_token, but I have tried passing an authenticity_token as well with the same result. Thanks in advance.

    Read the article

  • Passing an instance variable through RJS?

    - by Elliot
    Hey guys here is my code (roughly): books.html.erb <% @books.each do |book| %> <% @bookid = book.id %> <div id="enter_stuff"> <%= render "input", :bookid => @bookid %> </div> <%end%> _input.html.erb <% @book = Book.find_by_id(@bookid) %> <strong>your book is: <%=h @book.name %></strong> create.rjs page.replace_html :enter_stuff, :partial => 'input', :object => @bookid The problem here is that only create.js doesn't seem to work (though, if instead of passing the partial I passed "..." it does work, so I know its that there are instance variables in the partial that aren't being reset. Any ideas?) So the final question, is how do I pass an instance variable to a partial through the create.rjs file? p.s. I know I will have duplicate div IDs, I'm not worrying about that for now though. Best, Elliot

    Read the article

  • Confused as to which Prototype helper to use

    - by user284194
    After reading http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html I just can't seem to find what I'm looking for. I have a simplistic model that deletes the oldest message after the list of messages reaches 24, the model is this simple: class Message < ActiveRecord::Base after_create :destroy_old_messages protected def destroy_old_messages messages = Message.all(:order => 'updated_at DESC') messages[24..-1].each {|p| p.destroy } if messages.size >= 24 end end There is a message form below the list of messages which is used to add new messages. I'm using Prototype/RJS to add new messages to the top of the list. create.rjs: page.insert_html :top, :messages, :partial => @message page[@message].visual_effect :grow #page[dom_id(@messages)].replace :partial => @message page[:message_form].reset My index.html.erb is very simple: <div id="messages"> <%= render :partial => @messages %> </div> <%= render :partial => "message_form" %> When new messages are added they appear just fine, but when the 24 message limit has been reached it just keeps adding messages and doesn't remove the old ones. Ideally I'd like them to fade out as the new ones are added, but they can just disappear. The commented line in create.rjs actually works, it removes the expired message but I lose the visual effect when adding a new message. Does anyone have a suggestion on how to accomplish adding and removing messages from this simple list with effects for both? Help would be greatly appreciated. Thanks for reading. P.S.: would periodically_call_remote be helpful in this situation?

    Read the article

  • Jrails and jquery-rails together?

    - by ecoologic
    I hope you forgive me if I'm a little confused about this. Jrails rewrites all the helper methods for rjs otherwise in prototype. Jquery-rails overrides rails.js (so I taught the rjs helpers as well, but I see it's not) and the rest of the libraries in jquery instead of prototype. Does it means that with just Jquery-rails I can't use rjs at all? Then do these gems work well together and let me completely forget prototype? Is there any disadvantage in using them together? I read some complaining about the fact that jrails uses jq 1.5 and now there is 1.8, but jquery-rails gives me the last version (is there retro compatibility?), but how will this affect my development (using both the gems together)? I mean have you got some examples of jquery-ui plugins I can't use or I could have problems with? Any help is appreciated. Don't get me wrong, I'm not against prototype, just I keep on having conflicts over conflicts using both of them, and I have to chose I pick Jquery.

    Read the article

1 2 3  | Next Page >