Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
642 views
in Q2A Core by
edited by
Once a user hits the add answer button he gets redirected to the page and to his answer !

There and only there I want to show a field with extra info, may be a suggestion where to go next or social share buttons,

how could this be achieved ?

Any hint ?

 

EDIT

I think the js in ../qa-content/qa-question.js, needs to be modified, at least there are two functions which could help on this ?

 

function qa_submit_answer(questionid, elem)

and

function qa_answer_click(answerid, questionid, target)

 

It would be fully sufficient to get a parameter submitted, so that one knows that he is on the refreshed page after answering, from there, one can add a info box through the theme..

 

EDIT 2

 

OK through the theme there cant be processed anything as the page does not reload, so either one has to add the information through js, or one needs to trigger a page refresh...
Q2A version: 1.6.1

2 Answers

+2 votes
by
selected by
 
Best answer

I think you can just call your custom function from within the code block of qa_submit_answer().

Just after:

                qa_conceal(a, 'form');
 

you add for example:

                showUserNotification();

and outside of the function, you declare this function, guess you can use jquery as it is loaded already:

                function showUserNotification() {

$('<div id="object">').appendTo('body').html(html).css({ 'top': '200px', 'left': '300px', 'z-index': '10' });

               }

 

To #object you have to add the content you like, e.g. share buttons etc.

by
Thank You for the explicit answer, I can start from here.

I always thought that a user after having answered something needs more options to go ahead, now one can have that by showing a box under the new answer !
0 votes
by

It is cool suggestion. I think that several problem exist, but, how is the method to let jQuery modal form intervene? May this method be realized in plugin without core hacking?

  1. When page loaded, you replace javascript of "onclick" of submit button (name=qa-form-tall-button-ask).
  2. When user clicks submit button, jQuery modal form is displayed.
  3. Extra items are displayed into modal form.
  4. When OK button of modal form was clicked, contents of modal form are copied to extra field on page.
  5. When control returned from modal form, original javascript of submit button is executed by eval.

It may be necessary to extract extra items from database by Ajax...?
It cannot such easily come true...? blush

by
edited by
I found the thread by kai :

http://www.question2answer.org/qa/21384/trigger-javascript-function-answer-after-submitting-answer

And it was as i thought in the qa-question.js but I have no idea of java so i was trying the last two hours to  add something to:

                var e=document.createElement('div');
                e.innerHTML=lines.slice(3).join("\n");
               
//                var newElement = document.createElement('div');
//                newElement.innerHTML = "<div>Hello World!</div>";
//                e.appendChild(newElement);​​​​​​​​​​​​​​​​
               
                var c=e.firstChild;
                c.style.display='none';

But it does not work...???

I modified as well

e.innerHTML=lines.slice(3).join("\n");

to

e.innerHTML=lines.slice(3).join("\n OKOK");

that works and in each row of the answer div OKOK is printed out.

So if I can add something  than I can modify the output and show a box like:

Recommend on facebook | googe+ | twitter

But I dont figure out how to attach something...

And the example by Kai may be great but i dont now how to write such a function.
by
I misunderstood that you hope to display extra fields to another UI after "question".
by
However, both are very interesting features.
we could need more flexibility in these areas...
by
Yes. I think so.
...