MyBB Community Forums

Full Version: Cannot remove attachment when editing a post
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Upgraded to 1.8.20 (from 1.8.19).

For the life of me can't figure out why I can't do this now:
  1. Edit a post with attachments
  2. Find one of the attachments, and try to remove it
Every time I tried to perform this, it quits the end and return immediately to showing the thread.

I do have a custom theme, but comparing with the stock default template, it's mostly the same (difference is in the class attribute).
This is "post_attachments_attachment_remove" from the default template:

<input type="submit" class="button" name="rem" value="{$lang->remove_attachment}" onclick="return Post.removeAttachment({$attachment['aid']});" />



This is most likely a user error, but for the life of me I can't figure this out. The debug console did show an error, but that happened way too quick for me to debug. (Not sure how to set a break point in web dev). Any help?
(2019-03-05, 09:45 AM)snakeoilos Wrote: [ -> ]The debug console did show an error, but that happened way too quick for me to debug. (Not sure how to set a break point in web dev). Any help?

Hi,

open the browser inspector, Console (tab), and click in Console settings (gear icon in the right), and check Preserve log.
(2019-03-05, 09:56 AM)NoRules Wrote: [ -> ]
(2019-03-05, 09:45 AM)snakeoilos Wrote: [ -> ]The debug console did show an error, but that happened way too quick for me to debug. (Not sure how to set a break point in web dev). Any help?

Hi,

open the browser inspector, Console (tab), and click in Console settings (gear icon in the right), and check Preserve log.

Hi NoRules,

Thanks for that. Now I'm a step closer to figure out what I missed,


ReferenceError: templates is not defined[Learn More] general.js:118:4
    prompt https://www.snakeoil-os.net/forums/jscripts/general.js?ver=1820:118 
 removeAttachment https://www.snakeoil-os.net/forums/jscripts/post.js?ver=1820:97
 onclick https://www.snakeoil-os.net/forums/editpost.php?pid=2272:1 

Tried adding/removing attachments over here at myBB, and there is a yes/no prompt happening here.. Don't recall ever seeing this prompt pop up at my site, and I did managed to remove attachments when editing posts in 1.8.19.


Looking at this error, is this a template issue, or javascript? Seem to recall something about templates in headinclude, not sure if I added that back or not.. Sad The hunt continues.

Hopefully somebody can work this out before me, would appreciate that a lot!!

Update:
Thanks NoRules for that tip, it did help me isolate the problem. I'm missing something in headerinclude. Thought <!-- --> is a block comment. Turns out that's probably for HTML, not javascript.

Added this back in and it's now all working.

 var templates = {
 modal: '{$jsTemplates['modal']}',
 modal_button: '{$jsTemplates['modal_button']}'
 };
That solved it for me too! I just did a differ report on headerinclude template under ungrouped templates and showed me what was missing.
Thanks