Matt Stern

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: Prevent page reload #4582
    Matt Stern
    Participant

    Thanks a lot for your help – it has really guided me in the right direction to solve my issue. I believe I solved my issue by doing the following –

    I moved all of my forms onto another page – not separate pages though, one single page.

    I now have the following ajax/jquery code running that handles showing the correct form when it is selected:

    ;(function($){
    var ahref1;
    $(document).ready(function(){
      $(document).on('click', '.entry-content li a', function(e){
        e.preventDefault();
        ahref1 = $(this).attr('href');
        $('#formloader').load('/testpage ' + ahref1);
        return false;
      });
    });
    $(document).ready(function(){
      $(document).on('click', '.entry-content #formloader a', function(e){
        e.preventDefault();
        var ahref2 = $(this).attr('href');
        $('#formloader').load(ahref2 + ' ' + ahref1);
        return false;
      });
    });
    })(jQuery);

    This seems to work exactly as intended – once again, thank you for your time!

    in reply to: Prevent page reload #4576
    Matt Stern
    Participant

    Sure, let me just clarify a little to see if that helps-

    Originally, I had multiple different signup forms on the same page using the id=”” argument in the plugin shortcode.

    I then moved to surrounding each in a div with a unique id, so I could choose which to show and hide using a simple menu with an anchor/href/link to each div, and :target pseudo in CSS to show it.

    My final issue that I feel can be solved without too much effort – seeing from the post I found elsewhere that I will link to in a bit – is re-appending whatever the current fragment is after your plugin rewrites the url. This is the best possible option (besides rewriting the submission process to use jQuery/AJAX as you suggested) that I have found, as I am aware that your plugin wouldn’t know what div it was surrounded by.

    In “Option B” of this post http://stackoverflow.com/questions/2317508/php-get-value-from-url-after-sign/2317518#27370176 it describes how you can use javascript to pass this info to the PHP code used when those links are clicked. Whether this actually works, I don’t know, but it seemed like it was the right path.

    That’s why I am asking here, because I feel like it is tweaking of the code snippet in the SO link above, combined with simply adding the variable into the plugin code in a couple spots.

    Link to my signup page: http://summitsharks.net/volunteer-signup-page/

    Right now I have it all showing the same exact form (id=”1″) but once functional I’ll be creating a unique one for each link in the menu. Each is however surrounded by a uniquely id’ed div.

    Thanks again for taking the time to read through my essays here.

    • This reply was modified 8 years, 9 months ago by Matt Stern.
    • This reply was modified 8 years, 9 months ago by Matt Stern. Reason: add link
    in reply to: Prevent page reload #4563
    Matt Stern
    Participant

    I actually fixed a lot of my problem by showing and hiding the forms using :target CSS. One last problem would be appending the correct anchor to the url so that the correct form stays showing after:
    1) Clicking “Sign Up >”
    and
    2) Clicking “< Go back to sign up sheet”

    Currently, this is what happens:
    1) Starting URL: site.com/volunteer
    2) After user selects form name from menu: site.com/volunteer/#formX
    3) Form appears, user selects “Sign Up >”: site.com/volunteer/?sheet_id=1&task_id=2&date=2016-06-30
    *needs to have #formX still appended to the end.
    4)Manually adding #formX to the end, it works – then click “back to sign up sheet”, it once again drops the fragment.

    Would this be fairly easy to do using JavaScript in combination with the plugin’s php?

    For example, at line 778 of class-pta_sus_public.php, could you pass in a variable containing the fragment, which was collected using JavaScript?
    <a href="'.esc_url($go_back_url).' . $FRAGMENT">

    I’m not sure if your form is GET or POST or exactly how to complete this – I have very limited knowledge of PHP.

    Is there a short PHP function that could accomplish grabbing the fragment from the JavaScript function?

    Thanks in advance for your help, as well as creating a great free plugin.

    • This reply was modified 8 years, 9 months ago by Matt Stern.
Viewing 3 posts - 1 through 3 (of 3 total)