rjs

ASP.NET MVC AjaxHelpers recommended usage

It seems all the examples I come across specifiy an UpdateTargetId to render out the HTML content of the Ajax response. This is quite a bit different than how it's done in the Rails world, where the response content contains JavaScript code which manipulates the page. The Rails convention seems more powerful. What's the recommended usag...

Question regarding RJS and usage of link_to_remote

I was working on my website when I cam across this problem, I have 100 posts in my blog and I am paginating them 10 at a time, I display the 1st 15 and display a link at the bottom which basically is implemented using the link_to_remote tag. <%= link_to_remote "More Posts", :url => {:action => 'view' ,:id => link.to_i + 1} , :html => {:...

problem with link_to_remote in Rails 2.1

I am facing this strange problem with the following section of code <% if (@more == -1) %> <%= link_to_remote "More Posts", :html => {:id => 'more-link', :onClick => 'return false;'}%> <% else %> <%= link_to_remote "More Posts", :url => {:action => 'view' ,:id => @more.to_i + 1} , :html => {:id => 'more-link'} %> <% end %> Now whe...

order that code is executed in, in an RJS script

I'm trying to implement a carousel function that's ajax driven. In other words, fetching new "slides" through the controller". I'm using glider.js (with prototype). My RJS file needs to load the new element into the DOM, and then Glider is called. My simplified RJS looks like this: page.insert_html :bottom, "content", :partial => 'pos...

Nested link_to_function/insert_html does not work

Here is a simple example of the problem. http://gist.github.com/235729 In short, if you have a index.rhtml with: <%= link_to_function "A link to insert a partial with nested insert_html" do |page| page.insert_html :top, :with_a_nested_insert_html, :partial => 'example_partial_with_nested_insert_html' end %> And a _example_...

why is Ajax.Autocompleter setting the style for the div container for the results to display:none ?

my autocomplete call is showing nothing right now, because the div that i am inserting the ul into has its style set to display:none. using firebug, i can see the results are returned in a proper unordered list tag and when i edit the html from the firebug console and remove the style="display:none;", i see the autocomplete results. i ad...

Is RJS evil and why?

I heard a bunch of rails developer saying that RJS is evil. I've never used it since I always managed to do what I wanted using classic javascript or jquery so I didn't pay attention. Now I'm getting into some legacy code and there's RJS all over the place. So... is it true? What are the drawbacks/advantages of using RJS? ...

updating a select box based on another (Ruby on Rails)

I'm in need of a more complete example on how to update a select box based on the results of a second select box in Ruby on Rails. I asked about this already here. I've read through the feedback from that posting, but am not having any luck figuring this out, and I've been trying for hours. Anybody know of a better (and more complete) ex...

RJS or Javascript?

I've used RJS in the past for RoR projects and felt terribly constrained by what it could do. However, using Javascript alone felt/feels ugly and hack-y. This is particularly true when writing Javascript that manipulates Rails automagically generated from variable names. I haven't seen much talk about RJS in the blogosphere recently. Is ...

form_remote_for not executing RJS, just displays JS

Hi, I'm using prototype/rjs on rails 2.3.3 and ruby 1.86 and my form_remote_for to my "create" controller just displays the create.js.rjs instead of executing it. The strange this is that all the other action+rjs's work fine, just the "create" action isn't working Any help would be appreciated. Thanks in advance! UPDATE: To clarify, it...

RJS returns plain javascript without JS tags

Here is code on view in FeesController "show" action template: <div id="payers_controls"> <%= link_to_remote('New payer', :update => "payers_controls", :url => new_payer_url) %> </div> Here is new.rjs - belongs to PayersController "new" action page.replace_...

Rails ajax background requests

I have a remote_form which works 100% When a user clicks submit, it goes out grabs so data from the db or data scraped from another website, and updates the page seamlessly... The problem I'm having now, is that I'd like to do the same thing, but do it without having the user click the submit button with an onload event. I think I'm ...

Rails: Ajax form validations with error_message_on

I've been trying to get get some ajax validations going in my form and have been running into a bit of trouble I have code like this in my form: <% form_for @user, :html => { :id => 'user_form', :multipart => true } do |f| %> <%= f.label :username %><br /> <%= f.text_field :username %> <%= error_message_on :user, :username %> ...

facebox_render updating existing view

This is probably an RJS thing, but I'm a little unsure how to update a facebox properly if it contains a form. Let's say that I've got a sample app that does this: <%= facebox_link_to "Something", :url => some_path %> which renders a facebox (no issue here) like this: <% remote_form_for(@something) do |f|%> <%= f.error_messages %> .....

How do I override the RJS MIME Type in Rails 2.3?

I have an app running Rails 2.3.5 that has a JSON API for much of it. A contractor came in and did some work on the app and used RJS in a few places. Some of those controller actions that are using RJS for the main web site also need to be part of the API. The problem is that JSON API requests trigger the RJS responses, which is not w...

Linked List Dependent Select Boxes

So I haven't been doing this for long but I'm completely stuck on this. I have a model which looks like this (simplified for brevity): class ReqBreakdown < ActiveRecord::Base belongs_to :next_level #nil if lowest level belongs_to :previous_level #nil if highest level belongs_to :requirement_level end I need a way to build these...

Issues using a link_to_remote to change the state of the database?

hi, anyone know of any issues using a link_to_remote to change the state of the database? I'm taking about issues with spiders, google accelerator etc. Twitter seems to do it with no problem. Thanks ...

visual_effect after replace_html not working in rjs

Hi, In learning ruby on rails I've created a blog site. When the user adds a post via AJAX, the following rjs gets called: page.replace_html 'posts', :partial => @posts page.visual_effect :Highlight, 'post_' + @post.id.to_s However, the highlight isn't happening.. neither is any sort of effect even a hide. Clues: It works if I ju...

Confused as to which Prototype helper to use

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

Confused as to which Prototype helper to use (updated)

This is a continuation of http://stackoverflow.com/questions/2397874/confused-as-to-which-prototype-helper-to-use. My code has been updated to reflect other user's suggestions: (model) message.rb: class Message < ActiveRecord::Base after_create :destroy_old_messages def old_messages messages = Message.all(:order => 'updated_at ...