link-to-remote

Is there a :disable_with equivalent for link_to_remote?

青春壹個敷衍的年華 提交于 2019-12-21 20:38:59
问题 I have a link_to_remote and I want to make sure people can only click it once while waiting for it to return. Is there a good way to disable it after someone clicks it? (Changing the text of the link is nice too, but I want to disable it also to be sure). This is Ruby on Rails btw. 回答1: You can't disable a link, but you can change the href for example. So you can use :before or :loading hooks to "disable" the link using javascript . 回答2: I ended up replacing the link in the :before block like

Rails3 - How to send Javascript Variable to a controller's action with the link_to helper?

那年仲夏 提交于 2019-12-18 06:51:36
问题 If i have the following javascript code var myVar = 0; function setNewValforVar(newValue){ myVar = newValue; } and i'm calling setNewValforVar function n times so when I click on a link it'd send myVar value to the controller action in a remote link like <%=link_to "My Link",{:action=>"myAction"},:data=>''sval='+myVar',:remote=>true%> I Rails 2.3.x I'd do this with <%=link_to_remote "My Link",:url=>{:action=>"myAction"},:with=>"'sval='+myVar"%> and i was getting this on the controller's

Passing object from view to controller

可紊 提交于 2019-12-11 07:48:56
问题 Is there a way to pass a object, specifically a form_builder object used in a view, to an action in the controller? I am using a link_to_remote and want to update a variable in the controller and then add a new nested form element to my form via a render :update block. If I pass it as a param, it gets converted string and I can't seem to successfully pass a locals hash to the controller either. 回答1: No, you cannot pass an object from the view to the controller. All your logic should happen in

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

Is there a :disable_with equivalent for link_to_remote?

北城以北 提交于 2019-12-04 13:10:30
I have a link_to_remote and I want to make sure people can only click it once while waiting for it to return. Is there a good way to disable it after someone clicks it? (Changing the text of the link is nice too, but I want to disable it also to be sure). This is Ruby on Rails btw. You can't disable a link, but you can change the href for example. So you can use :before or :loading hooks to "disable" the link using javascript . I ended up replacing the link in the :before block like Edgard suggested: <div id="parent"> <%= link_to_remote "Click Here", {:url => "/some_long_url", :method => :post

Rails :confirm modifier callback?

我是研究僧i 提交于 2019-12-04 10:29:56
问题 I want to call a javascript function that will be conditional upon a user's response to the confirm box. For example, I have the following anchor: <%= link_to 'Sign Out', destroy_session_path, confirm: 'Are you sure that you would like to sign out?', method: :delete %> Should I just abandon the unobtrusive javascript and bind my own jQuery callback to my anchor? Or is there some magical way to pass a callback function to the Rails url helper? I did not see any discussion of callbacks in the

Rails :confirm modifier callback?

不想你离开。 提交于 2019-12-03 05:54:18
I want to call a javascript function that will be conditional upon a user's response to the confirm box. For example, I have the following anchor: <%= link_to 'Sign Out', destroy_session_path, confirm: 'Are you sure that you would like to sign out?', method: :delete %> Should I just abandon the unobtrusive javascript and bind my own jQuery callback to my anchor? Or is there some magical way to pass a callback function to the Rails url helper? I did not see any discussion of callbacks in the documentation . By following the link_to source, I see that the :confirm modifier is passed to the