I'm not sure if this can currently be done, i couldnt see anything in the code, but let me know if i've missed something.
Use case - I have a page where i have embedded a node edit form directly under the node content. A user is able to ajax submit the node edit form to update the content. On the form submission i want the updated node to be returned to on 'complete' state so i can replace the old content with the updated content.

This would be a great addition, currently, i am having to fire off an additional AJAX GET request on 'complete' to get the updated data, and then replace it on the page. If it were to come back as part of the args object (or possibly in a different object) as a response from the form POST to the plugin_api then this would be only 1 ajax call instead of 2, and a resulting increase in performance.

Comments

kvvnn’s picture

I concur.

I'm using the same method as you are for node edits, but node adds are much more difficult.

I'm trying to use jquery's .ajaxSuccess function and dig out some sort of response, but not having much luck. Will post here if I nail it.

kvvnn’s picture

Here is what I am doing to get my node-view path once I submit an add-node form:

1) Ajax and Disable Redirect are enabled for my node type
2) I load the node-add form via jQuery's .load() :

$(mycontainer).load('node/add/nodetype #node-form', function(){
   // Stuff I want to do once the node-form has loaded
   alert("#node-form has loaded!");
});

3) I attach some code to the Submit button of this form


               //On Submit
                        $(mycontainer).find('#node-form').submit(function(){
                            
                        //Show new content when node-edit-form is done submitting
                            $(this).ajaxSuccess(function(event, request, settings) {

                            // if it was indeed our Ajax-module-enabled form that finished (we can get an infinite loop without this)
                                if (settings.type == 'post' && settings.url == '/node/add/nodetype') {
                                // get the response of the post
                                    var response = request.responseText;
                                // log the response in FireBug for debugging
                                    console.log( response );
                                // find the part of the Ajax module's response that starts talking about "redirect"
                                    var redirectStart = response.indexOf('"redirect"');
                                // add 13 characters to this to get to the beginning of http://site.com/node/nid
                                    redirectStart += 13;
                                    var redirect = response.substring(redirectStart,response.length);
                                    var redirectEnd = redirect.indexOf('"');
 /** important **/     // this redirect variable is the URL of our new node
                                    redirect=redirect.substring(0,redirectEnd);
                               // this is my container once again
                                    var blockContainer = $(this).parent().parent().parent();

                                // load the newly modified node block. Whats important here is the .load() function
                                // Everything around it is specific to my case
/** important **/           $(this).parent().parent().empty().load(redirect + ' #content-area .content', function(data) {
                                     // some function for after the new node is loaded
                                         alert("new node is loaded!");                                        
                                    });
                                }
                            });
                            // stop the page from redirecting to the new node
                            return false;

                        });