I currently have a link which when clicked calls a JavaScript function, which gathers some data and then uses ProtoType to submit a form...
function myFunction(){
data = someobject.getData();
$('myform').request({
parameters: {data:data, id:id,},
onSuccess: function(transport) {
document.location.reload();
...
I am trying to implement something seemingly very simple, and I have been beating my head against it for days at this point.
My desired end result is a Country select drop-down, tied to a State select drop-down, in such a way that when a given country is selected, IF states are known THEN those states are displayed in a select drop down...
Hi All,
I'm having an issue with rails involving javascript. Basically, I have the following code:
<ul id="all-points">
<%for point in Point.find(:all)%>
<%domid = "point[all][#{point.id}]"%>
<li class="available-point" id='<%=domid%>'>
<span>
<%= link_to_remote "ADD",:url => {:action => "add_point"},
:html ...
I am running into a strange problem.
I simply want to display a loading icon on the page when pressing a button.
If my call to form_remote_for contains Ajax options then the RJS script does not work.
This works ("loading" is hidden by the controller and RJS):
View:
<%=form_remote_for(:job, @job, {:url => {:action=>:create}}) do |f...
A feature in Reddit that I like is the ajax login - you enter your username and password on the front page and you never leave the front page even if there is a login error. If your login succeeds, I think it simply does something like a flash[:message] onto the front page to say "login successful". If I wanted to do this in Rails, would...
In a Ruby on Rails project I need to have a JavaScript function executed at the end of an Ajax call. My problem is that the values being passed into the JavaScript function being called with page.call are being wrapped up in quotes. Not too much of a problem if you're passing in strings but one of the values is a string representation of...
In Ruby on Rails I am working with an inline RJS and trying to find out which select option was selected by accessing selectedIndex property. For some reason unable to get this to work.
So, for example assigning / altering the selectedIndex property works great:
page['model_author_id'].selectedIndex = 5
But reading it and doing a co...
I'm new to Rails.
Javascript errors to an alert box injure my soul. Is there a way to send it to console.log() instead of alert()?
...
Hi, This is a pretty basic question but I can't find a good answer for it. I have a page in my Rails app where there are many objects that can be 'flagged'. Clicking the flag button should display a little box with a confirmation, little form, etc. The trouble is I can't figure out how to do this using RJS templates.
I've been usin...
Hi Currently i am working on a rails project . where i have to reload a partial page .
For example Create action
def create
# Some transaction to the database
respond_to do |format|
format.html {render :text => 'Add post' }
format.js
end
end
In my views posts/create.js.rjs i would like to reload the users/...
I'm trying to figure out how to use RJS to swap between two fields... i know how to replace the values but I can't seem to figure out how to read it.
Is it not possible to read values thru RJS? Only to replace?
<%= link_to_function "Swap" do |page|
#to_value = page[:currency_to].value
page[:currency_from].value = to_value...
I've got my autocomplete plugin working perfectly... except I have certain info that I want displayed in the autocomplete divs, but I don't want to end up when the user makes their selection.
Ie... I have an auto complete for currencies... they can search by either currency code or country... as they search it displays both info along w...
I am using jQuery to do an ajax call to my controller, and everything is working perfectly, except I can't quite get the return value that I want.
Let's say I have a collection of items, and I have the partial:
/app/views/messages/_message.html.erb
I am trying to render it as a big string of text/html like so:
format.js { render_to_...
I have an 'Save' button on my application, which saves a record via AJAX once edited. That code is working lovely. I have discovered a little bug though. If I click the save button, eventually the code below is invoked:
page.replace_html "status-#{@restriction.id}", "Saved."
page.delay(2) do
page.visual_effect :fade, "status-#{@restri...
I have a partial for a "guest" object which renders a link to a destroy action like this:
<%= link_to_remote "remove", :url => { :action => "destroy", :id => guest.id } %>
When called from an ERB view it works fine, e.g.
<div id="guests">
<%= render :partial => @event.guests %>
That is, it renders something like:
<a href="#"...
Hi!
How do you enforce DRY when you have shared code amongst rjs files? I'm trying to avoid the duplicated code in this example:
thanks!
...
Hi,
I'm not sure if I'm missing a known design pattern, but I keep coming up against the following problem with RESTful routes Rails.
In my example, I have a users controller that can respond in javascript (:js) format. The default response populates a page element with a list of the paginated users:
# /app/controllers/users_controlle...
I have a form_remote working perfectly for the form currency. The only change I want to make is the do away with submit button for a select box. So they just click the correct currency and it submits the ajax request.
<%= collection_select(:currency, :set, Currency.find(:all, :conditions => 'primary_source = "ECB"'), :code, :pretty_na...
How can I use RJS to modify CSS elements on a page? I'm looking to do modify the margin of a div to add a "margin-top: 2.8em;"
How can I access this with RJS or should i use something like
page << "document.getElementById('super-wrap').style.margin-top='2.8em;';"
Though this doesn't work.
Thanks
...
Im using a link_to_function / insert_html to insert a partial into the page. Everything works fine, until i add another link_to_function / insert_html into the partial that is being rendered into the page. All of a sudden the outer link_to_function link stops working and throws this error:
"missing } after property list" [Break
on ...