Is the only way to get a "return value" from the action called through a div tag via the :update => ''my_div'' entry? I want the value returned to be put into a string that I can manipulate in my :complete => ''my_complete_function()'' I *did* try to use the "store value in div" approach then read immediately via: alert(document.getElementById(''my_div'').innerHTML.length); but I get DIFFERENT versions in IE and FireFox !!!! BOTH are truncating the string (because the string contains marktup) and neither give me the verbetim string generated by my action. Any ideas how to circumvent using div as return value mechanism for link_to_remote? Pete -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Dec-07 15:19 UTC
Re: link_to_remote: return value from action into string?
On 7 Dec 2008, at 15:10, Peter Alvin wrote:> > Is the only way to get a "return value" from the action called > through a > div tag via the :update => ''my_div'' entry? > > I want the value returned to be put into a string that I can > manipulate > in my :complete => ''my_complete_function()'' >It''s already there. The context in which that javascript runs includes an object called request, which the is Ajax request object. In particular response.responseText is what you would expect it to be. Fred> I *did* try to use the "store value in div" approach then read > immediately via: > > alert(document.getElementById(''my_div'').innerHTML.length); > > but I get DIFFERENT versions in IE and FireFox !!!! BOTH are > truncating > the string (because the string contains marktup) and neither give me > the > verbetim string generated by my action. > > Any ideas how to circumvent using div as return value mechanism for > link_to_remote? >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Peter Alvin
2008-Dec-10 12:26 UTC
Re: link_to_remote: return value from action into string?
> It''s already there. The context in which that javascript runs includes > an object called request, which the is Ajax request object. > In particular response.responseText is what you would expect it to be.Thanks, Fred! However, I just can''t get it to work. If I''m reading your comment accurately, it looks like "response" is global? I''m trying this and it doesn''t work. The first alert fires but the second one does not. Plus, there are NO JavaScript errors in FF or IE... just "nothing at all" //link_to_remote passes :complete => "done()" function done() { alert(''done!''); alert(response.responseText); } I opened prototype.js to look "under the hood" and I see this: ... options.onComplete = (function(response, json) { ... Now, I have NO IDEA what this is, but it prompted me to change my code to this: function done(response) { alert(''done!''); //yes alert(response.responseText); //no } still, nothing! Finally, I tried this: I added response as param to my done function (see below), and still nothing. <%= link_to_remote ''CLICK'', :url => { :action => ''get_row'' }, :update => ''temp'', :complete => "done(response)" %> I''m so confused! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---