ujs

How do I load content with ujs, jquery and rails?

I'm trying to figure out the best way to insert content into a light box using rails UJS. I have a link that looks like this: <%= link_to "login", login_path, :remote => true %> Which produces html as such: <a data-remote="true" href="/login">login</a> So this all works great, and I've created the view file: user_sessions/new.js.er...

Upgrading :with parameter on a link_to_remote in Rails 3

What's the preferred UJS replacement for the Rails RJS helper ':with' parameter on a link_to_remote when upgrading to Rails 3 (using the new unobtrusive link_to... :remote => true syntax). eg. Replacement for: link_to_remote "Ajax Call", example_path(@thing), :with => "'foo=' + $('field').val()" Specifically, I'm looking into a link ...

Element.update is not a function [Rails 3 + JQuery]

I'm attempting to integrate JQuery into Rails 3. I've downloaded the rails.js file from http://github.com/rails/jquery-ujs and have included it in my app. I've also include JQuery. But when I attempt to do a simple page.replace like so: render :update do |page| page.replace_html "my_div", :partial => "my_partial", :locals => {:mylo...

Why doesn't this partial render with UJS / jQuery?

I'm trying to use jQuery to create posts with a form in my Rails 3 project. Here's what I have: look below for updated results create.js.erb: $("#posts").prepend("#{render(:partial => 'posts')}"); layouts/application.html.erb: ... <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&g...

How can I assign event handler to page objects using ajax and UJS

Hi all! Can someone please advise a good approach to this problem: On page load, an event handler is added to a page element. For example: // Javascript // when page is loaded... jQuery(document).ready(function) { // assign this handler to the buttonDiv element... jQuery("#buttonDiv").click(function() { // to alert "hello" ...

Simple UJS with jQuery not working in Rails 3

I'm creating a basic message board app with Rails 3. I want posts to be created with UJS/jQuery (submit the post with AJAX and clear the form). I thought this would be simple but I'm getting this error: Rendered posts/create.js.erb (64.5ms) Completed in 1771ms ActionView::Template::Error (undefined local variable or method `posts' fo...

remote action when clicking radio button in rails3

I'm upgrading a rails2 application that has some inline javascript to rails3 that I'm having trouble converting to UJS. Specifically, I can't figure out how to call change_values.js.rjs when clicking on a radio button. My rails2 code looks like this: <%= form_tag do %> <%= radio_button_tag "shared_name", "1st_button", true, :o...

Rails UJS rendering js.erb template in IE

I have a RoR app running rails 2.3.8 which makes use of the Rails 3 style UJS to bind data-remote forms instead of using form_for_remote, the controller responds with a js.erb file from the server. Works beautifully in FF, Chrome, and Safari, but when run in IE it prompts you to save a file and does not execute the JS. My research so f...

Rails 3 UJS driver events

Hi, According to Simone Carletti blog post, Rails 3 ajax helpers have changed a lot. We are supposed to write more javascript with rails 3 than we used to with rails 2. I tried to figure out how to show up an ajax loading gif -while an ajax query is running- in the "rails 3 way". I came up with this kind of code, which uses javascript ...

Rails 3 UJS dry Client + Server Side form validation

Form validation with jQuery is as easy as adding a classname to a field. Form validation with rails is as easy as putting a condition in to your controller (and/or model). I figure there should be a way to write the validations once and have them applied both client and server side. I've always been a fan of writing my own javascript,...