similar to: RJS: pass javascript variables in ruby calls

Displaying 20 results from an estimated 6000 matches similar to: "RJS: pass javascript variables in ruby calls"

2006 May 13
2
Using RJS in views without ajax
Hi! I can use RJS in views like this (without using ajax): <%=link_to_function("switch fields", update_page do |page| page.insert_html :before, ''date'', date_select(''exhibition'', ''date'') page.remove ''date'' end) %> Is there a way to move this RJS code into a function to separate file? .js files are not parsed
2009 Aug 07
2
calling a jQuery function from RJS/onclick
Hi, I have the following jQuery function on the head of my page. <script type="text/javascript"> jQuery.noConflict(); /* calling jNice on document ready */ jQuery(document).ready(function($) { $(''div.jNice'').jNice(); }); ..... </script> On page load, this gets called correctly. Now there''s a link on the page that lets me add more
2006 Jun 27
4
RJS Form Values
Hi, I have the following code : <%=link_to_function("? | China", update_page{|page| page[''tags_en''].value = "China" page[''tags_ch''].value = "?" }) %> This updates two text fields with the China and ?. However I want to append the values, not replace them. So I need something like this :
2006 May 28
1
RJS template / page.insert_html problem
Hiall, I have a rjs template which is calling page[:xxx].replace_html ... a couple of times and this works perfectly. However, in the same rjs file I have two calls to page.insert_html, which do not work. No error in development.log, nor error message in browser, the new content for the div simply isn''t changed at all. This is my code: ... action = "save_" +
2007 Dec 20
3
How-to spec this helper method?...
Hey gang, I have this dead-simple method defined in a helper: def add_category_link(name) link_to_function name do |page| page.insert_html :bottom, :categories, :partial => ''category'', :object => Category.new end end Where, and mostly how, would I spec this? I haven''t been able to find how to stub the rjs in a helper spec, so
2006 Nov 18
2
RJS page.delay timing issues
Hi. Has anyone ran into issues with the timing of page.delay. I have been testing in firefox, for the most part, and it seems that there is no reliability on when the page.delay timings kick in. What happens is that sometimes it will work fine, and the countdown looks great; other times it will just jump to the end and display everything at once, other times it will be jerky. I''m on a
2007 Oct 26
2
Appending to a textarea with RJS
Ok, this is driving me nuts. I''m trying to RJS some text into a text_area which may or may not have been written in by the user. if I page.insert_html :before, :after, :top, or :bottom, it either sticks the contents above or below the text box (but never in). If I do: page[:textboxid].value = "blah" it overwrites the contents of the textbox but doesn''t APPEND to it.
2006 Jul 05
0
Javascript repeating fields.
The one area I keep hitting my head against in Rails is repeating fields via javascript. I frequently have forms where one or more fields are actually broken out into sub tables because there can be multiple simultaneous values. Rails seems to want to you to use the [] construct in the form helpers (e.g. text_field(''employee[]'', ''name'')), but I can''t
2008 Sep 22
3
syntax error in RJS
I''m new to Ruby on Rails and came across a problem I could not solve alone. I''ve a pretty simple RJS file that looks like the following: 3.times do page.insert_html :bottom, ''messages'', ''test'' end page.call ''updateMessageWindow'' However this snippet gives a syntax error: ActionView::TemplateError (compile error D:/Eigene
2006 Jun 07
0
using inline insert_html to generate uniquely named elements
Hello all, I?m using some inline rjs to add content with a unique id like so: In the <head>: function add_fields() { html = ''<div id="'' + new Date().getTime() + ''">''; html += "<%= escape_javascript(render :partial => ''field_set'') -%></div>"; new Insertion.After("whatever", html); } In
2006 May 30
0
The ARTS Plugin: Another RJS Testing System
If you missed it, I''ve written a plugin for testing RJS that uses (basically) the same syntax as the RJS templates themselves. Here''s a taste: assert_rjs :alert, ''Hi!'' assert_rjs :assign, ''a'', ''2'' assert_rjs :call, ''foo'', ''bar'', ''baz'' assert_rjs :draggable,
2005 Dec 15
0
RJS Templates and the Replace semantics
I have an issue with the way replace_html works in an RJS template. This is a copy of a post on my blog (http://blog.craz8.com <http://blog.craz8.com/> ) that describes the problem and my working solution to the problem. If I have a collection of things that are output like this: <div id="things"> <% @things.each do |thing| %> <%= render :partial =>
2006 Apr 05
2
RJS and remote forms
I''ve run into what I think is a browser bug related to using remote_forms pushed in an RJS update. In my controller, I have an action that creates a new model and returns a form for one of its children: def create_party party = Party.create render :update do |page| page.insert_html :top, ''party-list'', :partial => ''party_header'',
2006 May 20
1
RJS returned javascript written straight to page
hi there, I have in my controller, the following to catch a link_to_remote: def form_part_add_personnel @credit_types = CreditType.find(:all) p = Credit.new() p.id = rand.to_s[2..-1] render :update do |page| page.insert_html :bottom, "script", :partial => ''films/form/personnel'',
2006 May 02
1
Very simple RJS not working in IE
My HTML: <div id="search_div" style="display: none;"> <table> <tbody id=''search_results''> </tbody> </table> </div> My RJS: page.insert_html :bottom, ''search_results'', "<tr><td>Test</td></tr>" page.show "search_div" Now, everytime this gets called, it adds a
2006 Aug 18
3
RJS templates for DOM manipulation
I want to do some DOM manipulation with JavaScript. Specifically I want to implement zoom in/out in a picture by changing it''s width/height attributes. Is it possible to do this using RJS or should I write javascript by hand? All the examples of RJS I''ve seen write the javascript in the result of an AJAX remote call. Where are the docs for RJS? All I''ve seen are blog
2006 Apr 19
4
RJS replace_html auto-closing tags
I''m using the following RJS template to spit out a div containing a list of projects: page.replace_html ''results'', ''<div>'' @projects.each do |p| page.insert_html :bottom, ''results'', p.name + "<br/>" end page.insert_html :bottom, ''searchresults'', ''</div>'' page.show
2006 Mar 03
1
rjs isn''t update_page problems
i have a list of, for example, meal_names. Basically, I can submit a name and the name I add shows up in the list.I had this working wehn i created an actual add.rjs template for it. So feeling good about my self, I attempted to move it all to the controller and use some update_page goodness. Now it the ajax middle doesn''t happen. I don''t get any errors but the list
2006 Jun 19
1
RJS Templates
I have a page that when a form gets submitted, I use page.insert_html to stick a div in another div. The problem is, when I want to refernce it later on, the IDs are not unique. So to get around this, I concatenated the id of the item to the end of the div name. Which is fine. I did the same in the RJS template as well, but it''s not finding that div. I tried it with string
2008 Jul 24
1
How to add link_to_remote element with RJS?
Hello, after executing an action, I add an <li> element to an existing list using a RJS template: page.insert_html :bottom, :contributors, "<li id=''contributor.#{@contributor.id}''>#{@contributor.user.name}</li>" but I need to add an image with a link_to_remote as I have in a partial page: <li id="contributor.<%= contributor.id