rjs

RoR: How to handle custom nested form's submit

↘锁芯ラ 提交于 2019-12-12 03:46:10
问题 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 presentation of the question will be somewhat complicated. Let's see an equivalent problem! Schema: publishers (id, name, address) books (id, title, publisher_id,

gmaps4rails map not showing when loaded dynamically using prototype

爷,独闯天下 提交于 2019-12-11 16:12:38
问题 I have a view with 3 tabs each representing a view of the data (Table, Map, Charts). When I click on the tab it blinds up the view before if runs switch_view.js.rjs <%= link_to_remote I18n.t('biomass_configuration_menu.button.view.table'), :url =>{:controller => :biogas_calculator, :action => :switch_view, :view => "table"}, :method => :get, :loading => visual_effect(:blind_up, "biomass_configuration", :duration => 0.5, :queue => 'front'), :html => {:id => "table_view", :class => "toggle_map

Redirecting main window from ajax call

拈花ヽ惹草 提交于 2019-12-11 07:39:47
问题 I have a ajax call to a controller that checks for authentication, when no authentication exists it sends the call onwards to the signin controller who checks if it is a xhr request. If it is it renders an rjs containing a page.redirect_to to the signin path and the main window is redirected to the signin page. This works flawlessly in google chrome but fails in Firefox. the only code in the rjs file is: page.redirect_to("http://localhost:3000/signin") As i said, it works flawlessly in chrome

YUI3 Uploader + Rails rjs

妖精的绣舞 提交于 2019-12-11 07:11:27
问题 I'm trying to use the YUI3 Uploader with a Rails 2.3.12 project. I've got it working up to the point of parsing the response after uploading. The response is an RJS file rendering a partial, to update an element on the page. This RJS works as expected when run via normal non-flash uploads, and it works as expected with the SWFUpload plugin. In Firefox, I get the error: Error: missing } after property list Source File: http://secure.symt.localhost:3000/training_videos/4/edit Line: 0, Column:

Rails 3 Link_to :remote is not triggering RJS

时光总嘲笑我的痴心妄想 提交于 2019-12-11 03:35:21
问题 I'm working to setup an AJAX action in rails 3 with the following code. The AJAX part of the code seems to work, but it does not request the correct file and my respond_to serves it the regular HTML. The routing information: resources :zones do resources :records end controller: def new @zone = Zone.new respond_to do |format| format.html format.js end end Link in view (haml): = link_to 'Add a zone →', new_zone_path, :remote=>true Generated HTML from link_to (also notice the failed rendering

Ajax flash message in ruby on rails

时光总嘲笑我的痴心妄想 提交于 2019-12-07 18:27:57
问题 I'm trying to show a flash message and render it with Ajax, but the message does not seem to be appearing until after I refresh the page. Here's my create.rjs file: page.insert_html :top, :feed_items, :partial => 'shared/feed_item', :object => @micropost page.replace_html :user_info, pluralize(current_user.microposts.count, "micropost") page[:micropost_form].reset page.replace_html :notice, flash[:notice] flash.discard Here's the relevant part of my application layout view: <div id= "notice">

RJS: Check for existing page element?

回眸只為那壹抹淺笑 提交于 2019-12-07 16:42:58
问题 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 . 回答1: I've come up on this many times where I have a conditional item that needs to be acted upon if it exists. Using page.select avoids the Null Value error. page.select('#dom_object

RJS: Using observe_field on select_tag

妖精的绣舞 提交于 2019-12-05 07:57:17
问题 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 in the dropdown-menu. Below you see the code I've written. It works using the 'Go'-Button but doesn't work by just changing the value in the dropdown-menu. What

RJS: Using observe_field on select_tag

非 Y 不嫁゛ 提交于 2019-12-03 20:28:55
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 in the dropdown-menu. Below you see the code I've written. It works using the 'Go'-Button but doesn't work by just changing the value in the dropdown-menu. What's wrong with my observe_category_select-helper? View-partial with dropdown-menu and project list <!--

RJS: Ajaxified select_tag

心已入冬 提交于 2019-12-02 01:28:31
问题 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 consists of all category names. The view partial where the dropdown-menu should be implemented. Below the dropdown menu is a list of projects that should change