Please upgrade here. These earlier versions are no longer being updated and have security issues.

force hard refresh after submit

jackmaessenjackmaessen ✭✭✭
edited January 2015 in Vanilla 2.0 - 2.8

I still had problems loading geshi syntax highlighting, mark V plugin ( @hgtonight made this) and signatures after submitting and editing a comment. They all needed a hard refresh. So i was looking for a way to force this refresh.

In the file: applications/vanilla/js/discussion.js there is this function:

// Hijack comment form button clicks.
   var draftSaving = 0;
$('.CommentButton, a.PreviewButton, a.DraftButton').livequery('click', function() {
// rest of code

I seperated the CommentButton from it and created the same function with at the end a window.location.reload();

/* submit buttons need a hard refresh */
    $('.CommentButton').livequery('click', function() {
// rest of the code and at the end
complete: function(XMLHttpRequest, textStatus) {
            // Remove any spinners, and re-enable buttons.
            $(':submit', frm).removeClass('InProgress');
            $('.DraftButton', frm).removeClass('InProgress');
            $(frm).find(':submit').removeAttr("disabled");
            if (draft)
               draftSaving--;
               window.location.reload(); /* force the refresh*/

         }
      });

I know this is not a proper way to do it because i edited one of the core files. Maybe someone knows a way to get the same result with a more proper way?

Comments

  • AnonymooseAnonymoose ✭✭
    edited January 2015

    There are a few more plugins which needs this. This is good. Take your javascript and move it into a plugin which adds a new .js file and then it can be stand alone.

    jackmaessen
  • jackmaessenjackmaessen ✭✭✭
    edited January 2015

    @Anonymoose Yes, i was already thinking about that to make a plugin of this. Good idea! The core files remain the same.

  • hgtonighthgtonight ∞ · New Moderator

    Kudos for getting it to work. :)

    That said, I would rather see the underlying issue get fixed. This is a bit like taking aspirin to get rid of your toothache rather than getting the tooth pulled/filled by the dentist.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • If you want to run some javascript after post submission, bind your handler to the "CommentAdded" event.

    $(document).on('CommentAdded', function() {
        //...
    });
    

    My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations

    • Vanilla APP » Learn more «
    • iOS & Android App for Vanilla - White label app for your forum
    jackmaessen
  • Great @Bleistivt ; i used the DiscussionRefresh plugin from R_J for this and i added at the bottom:

    $(document).on('CommentAdded', function() {
        window.location.reload();
    });
    

    Same result without editing the core files!

    Adrian
Sign In or Register to comment.