tseting an InPlaceEditor, I am trying the :onComplete option (code to be run, if update successful with server) even not fleunt with JS, I succeeded with an Ajax.Request onComplete: function(transport,element) { new Ajax.Request(''/profils/change_domain_category/'', {asynchronous:true, evalScripts:true, parameters:''new_domain_name='' + this.element.childNodes[0].nodeValue + ''&old_domain_key='' + ''#{value}'' });return false;}, I am trying a simpler function to remove a class name from the current element : onComplete: function(transport,element){ new removeClassName(this.element, ''red''); }" but it''s wrong.... I got an error ( invalid property id) why ? how should I write it correctly ? thansk fyl kad -- 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 -~----------~----~----~----~------~----~------~--~---
Kad Kerforn wrote:> tseting an InPlaceEditor,Please write automated tests for it, too... ;-)> I am trying the :onComplete option (code to > be run, if update successful with server) > even not fleunt with JS, I succeeded with an Ajax.Request > > onComplete: function(transport,element) { new > Ajax.Request(''/profils/change_domain_category/'', {asynchronous:true, > evalScripts:true, parameters:''new_domain_name='' + > this.element.childNodes[0].nodeValue + ''&old_domain_key='' + ''#{value}'' > });return false;},Tip: Put into your View a hidden <A> field (using link_to_remote), and use onComplete to trigger it, with something like onComplete: function() { $(''my_anchor_id'').onclick(); }. I don''t know if that would work, but I would start there, and it puts as much Ajax inside Ruby helper-generators as possible. And I think you can lose the ''transport,element'' if you are not using it...> I am trying a simpler function to remove a class name from the current > element : > > onComplete: function(transport,element){ new > removeClassName(this.element, ''red''); }" > > but it''s wrong.... I got an error ( invalid property id) why ? how > should I write it correctly ?What''s ''this'' at the time onComplete runs? Who runs onComplete? Try $(''my_explicit_id''). -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> And I think you can lose the ''transport,element'' if you are not using it... YES, THANKS > >> I am trying a simpler function to remove a class name from the current >> element : >> >> onComplete: function(transport,element){ new >> removeClassName(this.element, ''red''); }" >> >> but it''s wrong.... I got an error ( invalid property id) why ? how >> should I write it correctly ? > > What''s ''this'' at the time onComplete runs? Who runs onComplete?I have 2 dropdown selectors ''domain'' and ''category'', each one handled by specific in_place_collection_editor helpers 1- in_place_domain_editor(container, value = nil) url => set_proposal_domain # which return the selected domain name onComplete: AjaxRequest.. :action => change_domain_category parameters:''new_domain_name='' + this.element.childNodes[0].nodeValue change_domain_category renders via -> change_domain_category.rjs : page.remove ''category_selector'' #remove old category selector page.insert_html :after, ''domain_selector'', :partial => ''category_selector'' #insert new category selector based on new domain page.replace_html ''category'' , ''choose category...'' #no category selected yet, return text page[''category''].add_className(''red'') # set in_place_category_editor to class .red 2- in_place_category_editor(container, value = nil) url => set_proposal_category # which return the selected domain name obviously the ''category'' DOM element has class .red, but onComplete this class should be removed that''s why I would like to use onComplete: option in this in_place_category_editor Here is the view .. <div id="domain_selector" > <span id="domain"><%= my_prop.category.domain.name %></span> <%= in_place_domain_editor(domains, domain_selected) %> </div> <div id="category_selector"> <span id="category"><%= my_prop.category.name %></span> <%= in_place_category_editor(categories, category_selected) %> </div>> > Try $(''my_explicit_id'').I tried , unsuccessfully> > -- > Phlip > http://www.greencheese.us/ZeekLand <-- NOT a blog!!!-- 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 -~----------~----~----~----~------~----~------~--~---
Kad Kerforn wrote:>>> onComplete: function(transport,element){ new >>> removeClassName(this.element, ''red''); }" >>> >>> but it''s wrong.... I got an error ( invalid property id) why ? how >>> should I write it correctly ? >> >> What''s ''this'' at the time onComplete runs? Who runs onComplete? > > I have 2 dropdown selectors ''domain'' and ''category'', each one handled by > specific in_place_collection_editor helpersHow do you know they are ''this''? I suspect that a setTimeout() runs onComplete, so ''this'' might not be what you expect. Or maybe it is; add alert(this) to see.>> Try $(''my_explicit_id'').> I tried , unsuccessfullyTry again; it''s better than ''this''. And can''t removeClassName just take a string? -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> > Try again; it''s better than ''this''. And can''t removeClassName just take > a > string? > > -- > Phlip > http://www.greencheese.us/ZeekLand <-- NOT a blog!!!It''s up and running.... problem ? 2 commas in the script !!!! "function(resp){ new Element.removeClassName(''category'', ''red''); } I have 2 linked InPlaceCollectionEditor dropdown menu -- 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 -~----------~----~----~----~------~----~------~--~---