rjs

How can I use different RJS templates from the same rails controller?

I have a controller method that returns a list for a drop down that gets rendered in a partial, but depending on where the partial is being used, the RJS template needs to be different. Can I pass a parameter to the controller that will determine which RJS gets used? Here is the controller method, it is very simple: def services res...

RJS/Javascript conventions in rails

I'm starting to look into the whole world of RJS and Prototype/jQuery in rails and am a little bit confused. There seems to be no clear line of where to use one or the other. Say i wanted one of the "Active, Hot, Week" tabs like the ones here on SO. When pressing one of them i want to remove a css class (like "active-tab") from the one ...

MinusMOR type plugin with clean base?

I have read about MinusMOR but it seems not really being active supported. I love this idea- is there a better supported plugin for this purpose? ...

Javascript Include Tag Best Practice in a Rails Application

Say I need to call a javascript file in the <head> of an ERb template. My instinct is to do the usual: <head> <%= javascript_include_tag :defaults %> <!-- For example --> </head> in my application's layout. The problem of course becoming that these javascript files are loaded into every page in my application, regardless of whether or...

the example uses RoR ajax protoype helpers - How to do this in JQuery instead?

This page show how to do depended drop-downs using RoR+Prototype. Wonder if somebody would show how to do in JQuery insteaad http://pullmonkey.com/2008/3/30/dynamic-select-boxes-ruby-on-rails ...

RubyOnRails 2.2 + Jquery UI Sortable & AJAX: This is how I did it. Is there a better way?

Hello, In a Rails 2.2 project, I'm having users put together a list of projects into a portfolio object (i.e.: PortfolioHasManyProjects). On the page is a Rails form for regular text, titles etc., as well as 2 sortable lists; the lists are used for dragging projects from the global-project-list into your portfolio-project-list. It is s...

(Rails) What is "RJS"?

I've seen "RJS" and "RJS templates" mentioned in passing in blog posts and tutorials. I did a search, but I'm still unsure about it. Is it a technology specific to Rails, rather than a standard like JSON or YAML? I understand it's used for "generating JavaScript." Does it generate generic JS or Rails-specific JS requiring the Prototype ...

RoR: Multiple remote_function calls on single :onclick

I have two different methods that I want to execute when a user clicks a button. I have them working separately, but when I try to combine the two I get errors. The two ones I have currently are <%= image_tag('go_button.png', :id => "search_go_button", :class => "search_go_button", ...

Error using Nested insert_html partials in rails

So I have two nested partials with calls to insert_html. Basically each team has multiple players and I have an add player button and an add team button which each call a partial with the following helpers module TeamsHelper def add_team_link(name) link_to_function name do |page| page.insert_html :bottom, :teams, :parti...

RJS: Using observe_field on select_tag

The dropdown-menu (built by the select_tag) in my application should call the filter-category-action as soon as the user changes the value in the dropdown-menu AND hits the 'Go' button. Now I'd like to get rid of the 'Go' button and have an observer (observe_field?) call the filter-category-action as soon as the user changes the value ...

RJS: Ajaxified select_tag

Since I didn't get the expected answer on my last question I'll try to simplify and narrow my question: How can I build a dropdown-menu that uses AJAX (no submit-button) to call the show action of a certain controller? The following things are given: Model-Association is Categories HABTM Projects, therefore the dropdown-menu consi...

How to change html tag attribute value from RJS template?

Is it possible to change a html tag attribute value from an RSJ template? I know that there is a page.replace_html method, but it is not very useful in my case, since I have lengthy values of various attributes (such as alt, title of an image). What I want is change src attribute of a img tag in RJS. Is that possible at all? Thank you. ...

Redirecting to a 500 page when an AJAX call fails in Ruby on Rails

I'm working with an application built in Ruby on Rails with very poor error handling right now. If a controller method is executed via ajax, and that method results in a 500 (or 404 or any other response) the 500.html page is rendered and returned as the result to the AJAX request. Obviously the javascript doesn't know what to do with th...

RJS: Check for existing page element?

I have a textfield with the id "foo" that sometimes exists and sometimes not. If it exists I'd like to fill in a certain value. How do you do this by using RJS (in Rails 2.2)? I tried this and it doesn't work: if page[:foo] page[:foo].value = "bar" end I get TypeError: Null Value if the textfield doesn't exist. ...

How can I detect if an html page element exists by using RoR RJS Template code?

I tried several ways but all are failing. ...

Rails: link_to_remote update doesn't render the view

Hi, I have a link_to_remote to render the edit action of an object. But all it does is update the Dom Element with this response try { } catch (e) { alert('RJS error:\n\n' + e.toString()); alert(''); throw e } My link looks like this: = link_to_remote t("txt.edit"), :update => dom_id(comment), :url => edit_comment_path(comment.id) ...

Generate a file list based on an array

Hi all I tried a few things but this week i feel like my brain's having holidays and i need to complete this thing.. so i hope someone can help me. I need to create a filelist based on a hash which is saved into a database. The has looks like this: ['file1', 'dir1/file2', 'dir1/subdir1/file3'] Output should be like this: file1 ...

Access the value of an unsent form to use for remote_function

I'm curious how to solve this in a clean way. I've read a few forum posts but couldn't do something that works. I have a dropdown which — on change — should change a value for a remote_function. The remote_function only needs to be called when the propriate radio button is enabled. select: download <-- should affect rjs call to get a...

RJS method outputting raw javascript

I've got a page where I'm dynamically adding elements to a from a series of select boxes. I'm using RJS to do this and it's working great. Now, these elements in the div are a series of that are accompanied by Delete buttons, in case the user wants to remove a textarea. Here's where I'm hitting a wall. Here's the code that runs the De...

Running a rails RJS template from a jquery get request

I am using Rails and jquery with RJS templates to perform various AJAX requests. For most of my Ajax stuff I attach a submit handler to the form in my application.js as follows: $('#tagging_flickr_photos').submitWithAjax(); $('#tag_submit').click(function() { $('#flickr-photos-status').show(); }); This calls the form action whic...