Skip to content

Instantly share code, notes, and snippets.

@wallace
Created July 7, 2009 20:58
Show Gist options
  • Select an option

  • Save wallace/142365 to your computer and use it in GitHub Desktop.

Select an option

Save wallace/142365 to your computer and use it in GitHub Desktop.
# rails controller action renders text like this
render :text => "alert('#{messages}');"
# in response to a request that calls this js function onclick.
function saveAsReport() {
if (!currently_saving) {
var name = prompt('Please enter a name for this new report.', $('report_name').value);
if (name != null) {
$('report_name').value = name;
currently_saving = true;
var querystring = $('queryForm').serialize();
var url = '/reports/create';
new Ajax.Request(url, {
method: 'post',
parameters: querystring,
onSuccess: function(response) {
//closeSaveModal();
eval(response.responseText);
currently_saving = false;
report_is_updated = false;
$('save_btn').style.display = "none";
}
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment