Reputation: 65183
<%= link_to_remote "<span class='button_sprite_star'></span>Save Changes",
"unsaved_changes = false; $('edit_content').submit();",
:class=>"save action_button" %>
I'm using remote_form_for (the form works when I click the submit_tag in the form).
The reason why I want to have a different sumbit button, is because of how I'm doing the style of the page. The control buttons are outside the scope of the form.
I know my above method works for regular form_for's, but when the form is a remote_form_for I get this back:
try {
unsaved_changes = false;
Element.update("content_name_361", "Basic Agressive Pool Theory");
enablePreviewLink();
completeSave();
} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('unsaved_changes = false;\nElement.update(\"content_name_361\", \"Basic Agressive Pool Theory\");\nenablePreviewLink();\ncompleteSave();'); throw e }
which is an AJAX response... but why is that getting sent to a new page instead of the page I was already on?
I'm using ruby 1.8.7 and rails 2.3.8
Upvotes: 0
Views: 104
Reputation: 65183
Solved by making it call this function instead of calling the form's submit:
ajax_sumbit = function(e){ // e is a jquery object of the form
$j.ajax({
type: "POST",
url: e.attr("action"),
data: e.serialize()
});
}
});
Upvotes: 1