When using something like link_to_function "Label", "some_function(this);" the ''this'' references the href generated by the rails link_to_function. When using something like link_to_remote(task.id_description, {:update => {:success => "div1", :failure => "div2"}, :url => {:action => :some_action, :id => id}, :id => id, :before => "Element.show(''spinner'')", :complete => "Element.hide(''spinner''); some_function(this)"}) the ''this'' references something different, I believe the Ajax call itself. Is there a way of accessing the href as you can in the link_to_function? I want to be able to access it so I can change its className to indicate its been selected and change all the other hrefs on the same level to be unselected. Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You should be able to do this: link_to_remote(task.id_description, {:update => {:success => "div1", :failure => "div2"}, :url => {:action => :some_action, :id => id}, :id => id, :before => "Element.show(''spinner'')", :complete => "Element.hide(''spinner''); some_function(''# {id}'')"}) On Feb 2, 2:00 pm, Ben <benpe...-KuiJ5kEpwI4qdlJmJB21zg@public.gmane.org> wrote:> When using something like > > link_to_function "Label", "some_function(this);" > > the ''this'' references the href generated by the rails > link_to_function. > > When using something like > > link_to_remote(task.id_description, > {:update => {:success => "div1", :failure => "div2"}, > :url => {:action => :some_action, :id => id}, > :id => id, > :before => "Element.show(''spinner'')", > :complete => "Element.hide(''spinner''); some_function(this)"}) > > the ''this'' references something different, I believe the Ajax call > itself. > > Is there a way of accessing the href as you can in the > link_to_function? I want to be able to access it so I can change its > className to indicate its been selected and change all the other hrefs > on the same level to be unselected. > > Thanks--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Isn''t that just going to pass in the value of the variable ''id''? ''this'' actually references an object in the DOM and thats what I need from the function_to_remote so I can then manipulate it and other objects in relation to its position within the DOM. Thanks On 2 Feb, 19:13, Daly <aeld...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You should be able to do this: > > link_to_remote(task.id_description, > {:update => {:success => "div1", :failure => "div2"}, > :url => {:action => :some_action, :id => id}, > :id => id, > :before => "Element.show(''spinner'')", > :complete => "Element.hide(''spinner''); some_function(''# > {id}'')"}) > > On Feb 2, 2:00 pm, Ben <benpe...-KuiJ5kEpwI4qdlJmJB21zg@public.gmane.org> wrote: > > > When using something like > > > link_to_function "Label", "some_function(this);" > > > the ''this'' references the href generated by the rails > > link_to_function. > > > When using something like > > > link_to_remote(task.id_description, > > {:update => {:success => "div1", :failure => "div2"}, > > :url => {:action => :some_action, :id => id}, > > :id => id, > > :before => "Element.show(''spinner'')", > > :complete => "Element.hide(''spinner''); some_function(this)"}) > > > the ''this'' references something different, I believe the Ajax call > > itself. > > > Is there a way of accessing the href as you can in the > > link_to_function? I want to be able to access it so I can change its > > className to indicate its been selected and change all the other hrefs > > on the same level to be unselected. > > > Thanks--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Ben, So when I put my code snippet in my app, this is the rendered html: Ruby: <% id = "user_#{@user.id}" %> <%= link_to_remote(@user.login, :update => {:success => "div1", :failure => "div2"}, :url => {:action => :some_action, :id => :some_id}, :before => "Element.show(''spinner'')", :complete => "Element.hide(''spinner''); some_function(''#{id}'')", :html => {:id => id}) %> HTML: <a onclick="Element.show(''spinner''); new Ajax.Updater ({success:''div1'',failure:''div2''}, ''/content/some_action/some_id'', {asynchronous:true, evalScripts:true, onComplete:function(request) {Element.hide(''spinner''); some_function(''user_1006137'')}}); return false;" id="user_1006137" href="#">test-J0of1frlU80@public.gmane.org</a> Is this what you are looking for? On Feb 2, 2:30 pm, Ben <benpe...-KuiJ5kEpwI4qdlJmJB21zg@public.gmane.org> wrote:> Isn''t that just going to pass in the value of the variable ''id''? > > ''this'' actually references an object in the DOM and thats what I need > from the function_to_remote so I can then manipulate it and other > objects in relation to its position within the DOM. > > Thanks > > On 2 Feb, 19:13, Daly <aeld...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > You should be able to do this: > > > link_to_remote(task.id_description, > > {:update => {:success => "div1", :failure => "div2"}, > > :url => {:action => :some_action, :id => id}, > > :id => id, > > :before => "Element.show(''spinner'')", > > :complete => "Element.hide(''spinner''); some_function(''# > > {id}'')"}) > > > On Feb 2, 2:00 pm, Ben <benpe...-KuiJ5kEpwI4qdlJmJB21zg@public.gmane.org> wrote: > > > > When using something like > > > > link_to_function "Label", "some_function(this);" > > > > the ''this'' references the href generated by the rails > > > link_to_function. > > > > When using something like > > > > link_to_remote(task.id_description, > > > {:update => {:success => "div1", :failure => "div2"}, > > > :url => {:action => :some_action, :id => id}, > > > :id => id, > > > :before => "Element.show(''spinner'')", > > > :complete => "Element.hide(''spinner''); some_function(this)"}) > > > > the ''this'' references something different, I believe the Ajax call > > > itself. > > > > Is there a way of accessing the href as you can in the > > > link_to_function? I want to be able to access it so I can change its > > > className to indicate its been selected and change all the other hrefs > > > on the same level to be unselected. > > > > Thanks--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---