Ajax InPlaceEditor

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

Kad K. wrote:

tseting an InPlaceEditor,

Please write automated tests for it, too… :wink:

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 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
Redirecting... ← NOT a blog!!!

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

<%= my_prop.category.domain.name %> <%= in_place_domain_editor(domains, domain_selected) %>
<%= my_prop.category.name %> <%= in_place_category_editor(categories, category_selected) %>

Try $(‘my_explicit_id’).
I tried , unsuccessfully


Phlip
Redirecting... ← NOT a blog!!!

Kad K. 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 helpers

How 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 , unsuccessfully

Try again; it’s better than ‘this’. And can’t removeClassName just take
a
string?


Phlip
Redirecting... ← NOT a blog!!!

Try again; it’s better than ‘this’. And can’t removeClassName just take
a
string?


Phlip
Redirecting... ← 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