Commit 7aa5fb76 authored by Jérome Perrin's avatar Jérome Perrin

discussion: remove temporary hidden input added for click

When clicking "Reply" on a discussion post, this script adds a hidden input to mark which post we are replying to.
This cause problem  when ctrl+clicking reply to reply in a new tab, because it leaves the page with the extra hidden input, which cause problems, like clicking reply again cause `Error Value: You are not allowed to access '['1', '1']`' in this context , or clicking change page will reply.

This is a minimal effort fix, just remove the added element after click.

/reviewed-on nexedi/erp5!823
parent b3c56f2b
function deleteDiscussionPost(id){
/* this will add respective input box for delete post id (so multiple delete buttons can
safely coexist in one HTML page with one HTML form */
$("form").append('<input type="hidden" name="discussion_post_uid" value="' +id + '">');
clickSaveButton("DiscussionThread_deleteDiscussionPost");
function clickSaveButtonWithDiscussionPostUidHidden(id, buttonName) {
/* this will add respective input box for reply post id (so multiple reply buttons can
safely coexist in one HTML page with one HTML form.
Once the button was clicked, the hidden input is removed (so that this can be used
multiple times without reloading).
*/
var hiddenInput = $('<input type="hidden" name="discussion_post_uid">'),
form = $('form');
hiddenInput.val(id);
form.append(hiddenInput);
clickSaveButton(buttonName);
hiddenInput.remove();
}
function redirectCreateCitedNewDiscussionPost(id){
/* this will add respective input box for reply post id (so multiple reply buttons can
safely coexist in one HTML page with one HTML form */
$("form").append('<input type="hidden" name="discussion_post_uid" value="' +id + '">');
clickSaveButton("DiscussionThread_redirectCreateNewDiscussionPost");
function deleteDiscussionPost(id) {
clickSaveButtonWithDiscussionPostUidHidden(
id,
'DiscussionThread_deleteDiscussionPost'
);
}
function redirectCreateCitedNewDiscussionPost(id) {
clickSaveButtonWithDiscussionPostUidHidden(
id,
'DiscussionThread_redirectCreateNewDiscussionPost'
);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment