Ajax InPlaceEditor

Kad Kerforn 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 <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').

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 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?