I wrote an IE specific "In Place Editor" back in 2003. Now I need it to be cross browser. I decided to turn to script.aculo.us; having been happy with its easy "new Effect.foo" goodies.
Although the main script.aculo.us InPlaceEditor usage seems to be to update the server when the user clicks "ok", all I want right now is the cross browser benefit. When the editor is updated, I want a hidden form element to hold the new updated text, as well as the default behavior of showing the user the new updated text. After several form fields are updated by the user, the user will press Submit on the entire form and the page can use existing code to do the real server side database committed update. Wanting to stay as far away from JavaScript as I can (especially cross browser concerns), I'm not understanding why the following code doesn't work; although I'd guess it has to do with Closures, which I have no interest in learning ( although this looks great if I actually was interested http://www.jibbering.com/faq/faq_notes/closures.html ). It seems to me that on window load, document should know about hid_data_div and the inner function should know about document (so I don't know if Closures would be what I'd need to research anyway). However I do not see the alerts where hid_data_div is involved, and I don't see an error in the Firefox Console. Alerts after the apparently failed code do not run. But remove the hid_data_div alert code and 'onComplete Completed 2' works. And onload, Method1 and Method2 work. How can I address arbitrary elements on my page from within a callback such as onComplete? Or how would you recommend I update a standard form field using the InPlaceEditor, so that a later form submit can use existing code to do the real back end updates? window.onload = function(){ new Ajax.InPlaceEditor('id', 'url', { onComplete: function (transport, element) { new (Effect.Highlight)(element, {startcolor: this.options.highlightColor, keepBackgroundImage: true}); alert('onComplete Completed 1'); alert("onComplete Method1: " + document.getElementById ("hid_data_div").value); alert("onComplete Method2: " + $('hid_data_div').value); alert('onComplete Completed 2'); }} ); alert("Method1: " + document.getElementById("hid_data_div").value); alert("Method2: " + $('hid_data_div').value); } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---