rjs

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

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 :fad...

RJS code returned doesn't execute

I am using jQuery with rails. I am trying to make a PUT request to update a task. The call is made successfully. However, the javascript code returned does not execute. The code is returned alright but it just does not execute. Here is the jQuery put request i am making. $("#droppable_<%= bin.id -%>").droppable({ drop: function(e...

Rails 3 and RJS

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 :bot...

Using ajax actions with google friendly route

I am attempting to beautify my routes so that they follow the syntax of lists/name-of-list/id as per here: http://gregmoreno.ca/how-to-create-google-friendly-urls-in-rails/ I have defined a new route like so: map.list_permalink 'lists/:name/:id', :controller => 'lists', :action => 'show' Everything works fine, but my existing ajax met...

format.js response doesn't execute

Hi, I use Rails 3.0.0 Beta following an action, my RJS view returns JavaScript, but the code is not executed In Firebug I see in my response $('polaroids').insert("<li>\n <a title=\"4204497503_a0c43c561d.jpg\" href=\"#\">\n <img alt=\"4204497503_a0c43c561d.jpg\" src=\"/system/photos/279/original/4204497503_a0c43c561d.jpg?12688573...

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

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 ...

RJS error: TypeError: element is null

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...

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

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 r...

How to use visual_effect on DOM after loading the page?

I would like to make one of the div's hidden while rendring. After page is loaded I would like it to appear on the page using virtual_effect. I know how to do it in JS / jQuery. Is that possible with pure Ruby code using Prototype? update_page_tag doesn't really solves the problem It work ok with :highligth, but I can't get it to work...

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

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 ...

Rails RJS template displays code instead of the html page

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 p...

Sortable_element with RJS does not working

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, ...

How to scroll the page with rjs?

How can I scroll the page to a partial, which got inserted via rjs? page.insert_html :bottom, :comments, :partial => 'comment', :object => @comment ...

Ruby 'if' condition in rjs

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. ...

Page replace with RJS

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}", :part...

adding visual effects to RJS before action rendered

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", {...

call a Javascript function from controller more than once (in Rails)

hi. I have a multiple file upload form(html5) and want to update my view as soon one of the images is transfered to my image server. Currently I upload the files with ajax and use response_to_parent to update my upload view when all images are transfered to the image server. Is it possible to call a Javascript function from the cont...

Inserting AJAX page.insert_html for dynamic divs

I'm running into a little hiccup with my AJAX creation of comments for posts. Everything works great but I am doing this in the index.html.erb view so the create.js.erb is finding the first div that says "comments" and inserting the comment there. I know how to create a post specific div by using: <div id="comments_<%= post.id %> B...

Cannot render javascript from controller

I want to display a modal window with an error message, when the user has entered something invalid in a form, but render another action if everything is ok. However, when I try to display the modal window with render :js => "jQuery.facebox(#{...})" only the actual javascript called is displayed: try { jQuery.facebox(...) } catch (e...

Working Mootools on Rails solutions?

There are several questions about this already, but they are from awhile ago, so here goes: I have this half-made project that was built using prototype, but am looking into moving to a javascript library I am way more familiar about: mootools. Is there a way so I don't have to change any of my current rjs? e.g. remote_form_for Thank ...