XF 2.1 Fire javascript after posting / editing

ForumGeek

Member
Hi there,

as I mentioned in my other thread I have replaced the rendering of the [ IMG ] bb code by a lazy loading of the images (I cannot use the browser function as I trigger the JS file which implements the lazy loading depending on the consent given by a cookie banner).

This results in the problem that after a reply is posted or a post is edited any image contained in the post will not be shown until a function UpDateLazy(); is triggered.

In case of the preview-button I modified XF.PreviewClick in the js/xf/core/action.js file (added the update function just after XF.layoutChange(); ).

However, I was not able to find the corresponding files where I have to place the call to the update function in case of submitting or editing a post/thread.

I also tried something like
Code:
        <script type="text/plain">
        $(document).on('ajax:complete', function($data, $status, $xhr) {
       UpDateLazy();
});</script>

as well as

Code:
<script type="text/plain">
(function ($, document)
{
    $(document).on('xf:reinit', function ()
    {
       UpDateLazy();
    });
})
(jQuery, document);
</script>

Although this seemed to work at first glance it leads to an endless displaying of the progress bar (at the top of the display) when switching from the WYSIWYG editor mode to the bb code editor mode or backwards.

Does anyone have an idea how I can fire the update function upon an editing or submit event?

Thank you in advance!
 

ForumGeek

Member
Here is my (not very elegant )solution to this problem:

I modified the lightbox_macros template so that it adds
Code:
<script>
UpDateLazy();
</script>
as part of the [ IMG ] tag (only if viewed by a registered user!).

So whenever a member previews or updates a message and the lightbox_macros template is applied the update function will lazy load the image (unfortunately when viewing a thread the update function will be called as often as there are images available in the thread page but this does not seem to impact performance).
 
Top