evalScripts:true does nothing with Ajax inplace editor

1.2k Views Asked by At

I have the following code to create an inplace editor:

new Ajax.InPlaceEditor('artifact_pretty_display_date_110_in_place_editor', '/artifacts/set_artifact_pretty_display_date/110', {evalScripts:true})

The response looks good to after I change a date:

Element.update("artifact_pretty_display_date_110_in_place_editor", "12/06/2008");
Element.update("artifact_visible_display_date_110", "12/06/2008");
Element.update("flash_message", "<div class=\"flash_message\" style=\"display:block;\">\r\n            The Document's date was changed to 12/08/2008. \r\n</div>");
Element.update("flash_error", "<div class=\"flash_error\" style=\"display:none;\">\r\n\r\n \r\n</div>\r\n");

The only issue is my inplace editor field is actually showing this response, it is not getting eval'd. It is like setting evalScripts to true does nothing. Anyone know why this is happening?

Thank you!

2

There are 2 best solutions below

1
On

Looking at the docs it doesnt seem like evalScripts is a valid option in that context,i think your code needs to look like this:

new Ajax.InPlaceEditor('artifact_pretty_display_date_110_in_place_editor', '/artifacts/set_artifact_pretty_display_date/110', ajaxOptions:{evalScripts:true})
0
On

This turned out to be an issue with Scriptaculous's InPlaceEditor using an Ajax Updater as opposed to an Ajax Request object while also using page.replace_html. If you run into this error, it may be worth popping open controls.js from scriptaculous and making sure an Ajax Request object is used in the handleFormSubmission method. If not, you may need to set htmlResponse to true or depending on the version of scriptaculous you may need to set some other flag. That is exactly where my issue lied.