I am successfully using RJS to implement AJAX on a page.replace.html create.js.rjs. I am attempting to update two locations instead of one and after watching Ryan Bates Railscast I am very close (I think) but have a problem in the syntax of my /views/likes/create.js.rjs file. Here is the situation:
located at /views/likes/create.js.rjs ...
So it looks like on RoR, when Ajax (using form_remote_tag) returns a success code, Javascript is also returned to handle the visual effects. (this is the RJS mechanism)
using Fiddler, I do see the following response:
try {
Element.update("vote_score", "Score 58");
$("vote_score").visualEffect("highlight");
} catch (e) { alert('RJS erro...
I can't for the life of me get RJS to replace an element's innerHTML with an instance variable's attribute, i.e. something like @thing.name
I'll show all the code (simplified from the actual project, but still complete), and I hope the solution will be forehead-slap obvious to someone...
In RoR, I've made a simple page displaying a ran...
The following is in the text_field.
= f.text_field :title, :size => 50, :onchange => remote_function(:update => :suggestions, :url => {:action => :display_question_search_results})
The following is in display_questions_search_results.rjs.
page.insert_html :bottom, 'suggestions', :partial => 'suggestions'
Whenever the user types, I'...
Hey Everyone,
so I've watched http://railscasts.com/episodes/43-ajax-with-rjs
but I have a question:
In my view I have the following:
<div id="testly">
<%= render :partial => "test" %>
</div>
This works.
Using create.rjs to change the content in this div, I have the following in my create.rjs file:
page.replace_html :testl...
One of the most convenient things about RJS is its ability to render a partial so you have all your view code in one place:
# task/index.html.erb
<ul id="task_list">
<%= render :partial => 'task', :collection => @tasks %>
</ul>
# task/_task.html.erb
<li>
<% if task.is_completed %>
<%= task.name %> - <%= task.completed_date %>
...
In a form_tag, there is a list of 10 to 15 checkboxes:
<%= check_box_tag 'vehicles[]', car.id %>
How can I select-all (put a tick in every single) checkboxes by RJS? Thanks
EDIT: Sorry I didn't make my question clear. What I meant to ask is how to add a "Select/Un-select All" link in the same page to toggle the checkboxes.
...
i have put the following rjs in a controller... but it gives me the following error...
TypeError: Element.update is not a function
respond_to do |format|
format.js do
responds_to_parent do
render :update do |page|
page.replace_html 'errorLay', :text => "Page with the same name already exists."
...
Hi
I'm trying to pass a string with a link_to_remote call as the :id, and the string should be collected from an input field with and id of "movie_title".
<div id="search_list">Nothing here yet</div>
<br />
<% semantic_form_for @movie do |f| %>
<% f.inputs do -%>
<%= f.input :title, :class => "movie_title" %> <%= link_to_r...
I'm working with a that allows the user to add new contents to a shipment box. For example:
The user is setting up a shipment, each shipment can include multiple boxes, and each box can contain multiple contents.
So I have link_to_remote connected like:
In my shipment box partial:
<div class="shipping_box" id="shipping_box">
#so...
So I am using bhedana's google_maps plugin and have built a search for points that load on page render. I have all my points refreshing with
page.replace_html 'locations', :partial => 'locations'
but when I include
page.replace_html 'map', :partial => 'map'
in the same rjs file and have a partial that looks like
<%= @map.to_html...
I have a destroy action defined for a particular resource. On completion, it uses an rjs file with a visual effect to remove the resource from the page that it is being called from.
My problem is that the destroy action can be called from 2 different templates. And so the visual effect needs to be different, depending on which template ...
Is it possible to use ruby code in RJS files?
For example, the destroy.js.rjs file
if @template == "viewer"
page["viewing_registry_#{@viewer_registry.id}"].replace_html :partial => "shared/request_viewer_link"
else
page["viewer_#{@viewer.id}"].visual_effect :DropOut, :duration => 2.0
flash.discard
end
This is the RJS file call...
How to reload only the div id on a page?
I just need to reload a certain div.
in my controller I have
def mycontrolleraction
...
render(:update) do |page|
reload_only_the_div('adiv'), :controller => 'my_controller'
end
end
Is this possible?
...
I have two identical controllers Submissions and Activities, both using the default resource mapping for routes. I want to use some RJS for the show method, both of which can be accessed as such as a GET request:
/submissions/1.js
/activities/1.js
I have show.rjs inside their respective view folders like so:
../submissions/show.rjs
....
In Rails' RJS Adapter,
page['id'] // $('id')
accesses an CSS-id,
page['id'].property // $('id').property
a property of it. But how can I access an array index, e.g.
page.select('ul').value_at(2) // $('id').select('ul')[2]
Is there any way of doing this without writing:
page << "$('id').select('ul')[2]"
...
Hi,
I've recently started learning Ruby on Rails, based on RoR3 beta/RC. I had earlier been developing applications using other frameworks (like Django), where the JavaScript had been written completely on my own.
When developing application using RoR, I get confused by the two possible ways of implementing JavaScript: the "pure" one (w...
hi
i want to save the data to the table "Name" that i enter in prompt
page << "name = prompt('Enter name:'); "
please guide me with the code for the create functionality in RJS
thanks
...
Why does this:
<%= update_page_tag do |page|
page["femenino"].hide
end %>
Generates this?
<script type="text/javascript">
//<![CDATA[
try {
$("femenino").hide();
} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('$(\"femenino\").hide();'); throw e }
//]]>
</script>
I have the DIV with ID "femenino", the update_p...
Hello!
I managed to do almost all the way towards happiness with my custom form in ruby-on-rails, but the very last step is missing and it is impossible to find the answer on the net because of too many common words.
I believe that the answers to my questions are trivial for people who have done RoR for a time, but be warned that the p...