Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to control redirect behavior after reply submit??


  • huetherb
    Participant

    @huetherb

    I suppose this isn’t WordPress or BBPress specific, but trying to figure out if there is a WordPress way of doing this.

    I am using BBPress, and on some page, such as https://somesite.com/lesson/some-lesson/, I have a block with a link to a discussion topic. That link is of form

    <a href="javascript:void(0);" data-target="#myModal" data-href="somesite.com/forums/topic/required-discussion-1/" data-toggle="modal" class="openPopup"><h3 class="topictype-title">required discussion 1</h3></a>

    The modal popup is handled in bootstrap via

    
    <div class="modal fade" id="myModal" role="dialog">
       <div class="modal-dialog modal-xl">
          <div class="modal-content">
             <div class="modal-header"><button type="button" class="close" data-dismiss="modal">×</button><h4 class="modal-title">Class Discussion</h4>
             </div>
             <div class="modal-body"></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
          </div>
       </div>
    </div>
    

    And with jQuery

    
        $('body').on('click', '[data-toggle="modal"]', function(){
            $($(this).data("target")+' .modal-body').load($(this).data("href"));
        });
    

    What happens now, is after hitting submit, the modal goes away, and the forum topic page with the submitted reply is loaded: url https://somesite.com/forums/topic/required-discussion-1/#post-25847

    The thing is, after user submits from the modal, I want either

    **1) the refresh (so, going to https://somesite.com/forums/topic/required-discussion-1/#post-25847) to happen in the modal, or**

    **2) for the modal to simply close and user is returned to exactly as they were prior to modal popping up, that is, to https://somesite.com/lesson/some-lesson/**

    Ideas on how to ideally achieve these two behaviors? I have never worked with modals before, so curious what are some best practices here to get the desired behavior.

    Thanks!

  • You must be logged in to reply to this topic.
Skip to toolbar