Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Tip: Change ajax submitted content

+1 vote
304 views
asked Dec 5, 2014 in Plugins by q2apro

I had a tough time finding out how to change the HTML content that gets ajax-loaded after you submit an answer (clicking the answer button).

To modify the elements, you can use Jquery!

Example: Hide the comment button only below the submitted answer:

                            $('.qa-form-tall-button-answer').click( function() {
                                $(document).ajaxSuccess(function() {
                                    // hide ajax inserted button
                                    $('.qa-a-list-item:first-child .qa-a-item-main .qa-a-item-buttons .qa-form-light-button-comment').hide();
                                });
                            });
 

Hope that helps anybody.

Q2A version: 1.7 beta
commented Dec 10, 2014 by Vadim Molchanov
tell me plz where to insert this code to it to perform
commented Dec 10, 2014 by q2apro
1. Either use your advanced theme and output in the headscript the javascript.
2. Or write yourself a little plugin.
3. Or abuse the page.js in folder qa-content.

Note: Always enclose the code above in a jquery.ready function.
commented Dec 10, 2014 by Vadim Molchanov
I put this code in an existing plug-in (output in the headscript the javascript), but this code is called only when reloading the page and not load when clicking the answer button. My version 1.6. Class answer button same "qa-form-tall-button-answer" .
what could be the reason?
commented Dec 10, 2014 by q2apro
Check if the code is visible in the HTML.
commented Dec 10, 2014 by Vadim Molchanov
Ок, working!!! i forgot you tip: "Note: Always enclose the code above in a jquery.ready function."

Sanks! i use this for highlighting code.

Please log in or register to answer this question.

...