Hi, Firstly I am very new to Ruby on Rails but think its fantastic! :o) I am trying to figure out how I can call multiple functions from the drop_receiving_element :complete. I have the following code in my index.rhtml and it works fine. It calls the javascript function "additem" that is on the page. <%= drop_receiving_element "dcwindow", :update => "items", :url => { :action => "add" }, :accept => "products", :hoverclass => "cart-active", :loading => "Element.show(''indicator'')", :complete => "additem(element.alt,element.id)" %> But what I would like to do is call 2 functions. :complete => "Element.hide(''indicator'')", :complete => "additem(element.alt,element.id)" One way that I thought would be possible would be to call do something like this :complete => { :action => "myfunction" } Then from the server it could somehow call a javascript function that exists on the webpage def myfunction call_javascript_on_webpage "additem(element.alt,element.id)" Then somehow call Element.hide(''indicator'') end Also how do I get variables into myfunction? (ie element.alt, element.id)? Hope someone can help me :) Cheers, Kent -- Posted via http://www.ruby-forum.com/.
Sean Cribbs
2006-Mar-29 22:30 UTC
[Rails] Multiple calls from drop_receiving_element :complete
:complete => just adds calls at the end of the onclick chain. So if you want to do multiple, just put a semi-colon in between them. Make sure they have the correct return value so that the chain keeps being called (i don''t remember, is it false or true?). So your line would look like: :complete => "Element.hide(''indicator'');additem(element.alt,element.id)" Does this help? Sean Cribbs Web Services - KCKCC>>> whereiskent@hotmail.com 3/29/2006 3:30 PM >>>Hi, Firstly I am very new to Ruby on Rails but think its fantastic! :o) I am trying to figure out how I can call multiple functions from the drop_receiving_element :complete. I have the following code in my index.rhtml and it works fine. It calls the javascript function "additem" that is on the page. <%= drop_receiving_element "dcwindow", :update => "items", :url => { :action => "add" }, :accept => "products", :hoverclass => "cart-active", :loading => "Element.show(''indicator'')", :complete => "additem(element.alt,element.id)" %> But what I would like to do is call 2 functions. :complete => "Element.hide(''indicator'')", :complete => "additem(element.alt,element.id)" One way that I thought would be possible would be to call do something like this :complete => { :action => "myfunction" } Then from the server it could somehow call a javascript function that exists on the webpage def myfunction call_javascript_on_webpage "additem(element.alt,element.id)" Then somehow call Element.hide(''indicator'') end Also how do I get variables into myfunction? (ie element.alt, element.id)? Hope someone can help me :) Cheers, Kent -- Posted via http://www.ruby-forum.com/. _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060329/201c618c/attachment-0001.html