Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 28 total)
  • Author
    Posts
  • in reply to: Prevent scroll to form #41350
    GracesonGraceson
    Participant

    Hi All,

    This issue has finally been resolved!

    I was able to work with NhaTrang Net on the Meta Box Facebook group to troubleshoot this bug. For reference, setting allow_scroll="true" does what it has always done, and setting allow_scroll="false" disables all scrolling behavior as expected.

    The hotfix they just released makes everything work perfectly!

    in reply to: Using Composer in public repositories #41188
    GracesonGraceson
    Participant

    Hi,

    I don't think you are quite right since I have found one possibility.

    Turns out you can use composer config --global --editor to edit the local configuration. That way, you don't have to have the license key included in composer.json.

    https://stackoverflow.com/questions/54420663/php-composer-global-configuration-private-repositories-url-list

    Note: you will need to save and close the file when done like this: https://stackoverflow.com/questions/17535428/how-to-edit-save-a-file-through-ubuntu-terminal.

    Now, one can add the appropriate lines to .gitignore to keep things private from the public:

    
    .DS_Store
    composer.lock
    vendor/meta-box/
    vendor/composer/installers/
    

    This works decently, but I still think that MetaBox should update their repositories to support one of the authentication methods described on this page: https://getcomposer.org/doc/articles/authentication-for-private-packages.md. Please log this as a feature request.

    in reply to: Prevent scroll to form #41187
    GracesonGraceson
    Participant

    Hi Peter,

    I want to make sure I am understanding you. Do I have this correct: [mb_frontend_form id="my-ID" allow_scroll="true" ajax="true"] is supposed to scroll the page to the form message. [mb_frontend_form id="my-ID" allow_scroll="false" ajax="true"] is supposed to scroll the page to the top. Lastly,[mb_frontend_form id="my-ID" ajax="true"]` is supposed to not scroll at all. Is that right? Because, frankly, that sounds completely wrong to me.

    Your docs (https://docs.metabox.io/extensions/mb-frontend-submission/#submission-form) say that true is the default behavior. Therefore, [mb_frontend_form id="my-ID" ajax="true"] should be identical to [mb_frontend_form id="my-ID" allow_scroll="true" ajax="true"]. This also makes sense because before this feature allow_scroll="true" was the default behavior and I don't think you developers would want to introduce a breaking change. Also, if setting allow_scroll="false" is supposed to scroll to the top, then that is a very strange decision. Metabox is a framework, and that is a very opinionated choice for a framework to make. Therefore, my guess is that this feature is simply broken.

    However, you should know this product better than I, and you say it is possible. Therefore, I expect you to be able to demonstrate an example where the page is not scrolled at all when a frontend form is submitted via ajax. Please send a screen recording that shows the code and the desired behavior. Then I will try to replicate it.

    in reply to: Using Composer in public repositories #41172
    GracesonGraceson
    Participant

    Making the repository private is a very strange suggestion considering you have made this: https://github.com/wpmetabox/awesome-meta-box

    In any case it sounds like you do not properly support this at the moment. Can you look into updating how the extensions work with Composer so that it is easy for people to keep their license keys private while making it easy to share/collaborate?

    in reply to: Prevent scroll to form #41171
    GracesonGraceson
    Participant

    I see, then this is not the feature that I hoped it was.

    Can you please instruct me on how to make it so that the page is not scrolled at all? I do not want it to scroll to the top. I do not want it to scroll to the form. I don’t want the frontend submission to change the scroll position at all.

    in reply to: Prevent scroll to form #41153
    GracesonGraceson
    Participant

    Sorry, that was a typo on my end.

    I saw no difference when allow_scroll="false" so I was testing to see if allow_scroll="true" did anything differently.

    In any case, I do not see this feature working. Can you please confirm on your end that this feature functions when allow_scroll="false"?

    in reply to: Prevent scroll to form #41138
    GracesonGraceson
    Participant

    Hi Peter,

    I noticed that MB Frontend Submission 4.2.0 appears to have this feature now. However, I can not make it work. I have the following shortcode [mb_frontend_form id="mvi_fa_frontend-form-fields" allow_scroll="true" ajax="true"]

    However, the page still scrolls. Can you confirm that this feature works as designed? I am using MB AIO 1.19.1.

    in reply to: Prevent scroll to form #40114
    GracesonGraceson
    Participant

    @Anh Tran

    Do you have any suggestions for this use case? My theme now prevents the user from scrolling the page while the modal is open, but the form submission still scrolls. Therefore, I think I need a solution that prevents MB Fontend Submission from running the animate scroll function that is in frontend-submission.js.

    Is there a more robust way for me to override this feature rather than modifying the source code itself? Or, will I need to wait for a new feature to be hopefully implemented first?

    Thanks,
    Graceson

    GracesonGraceson
    Participant

    Hi Peter,

    That is good to hear. Thanks for the update. Do you know when this new version of MB Frontend Submission will be released? Looks like it is not in AIO 1.16.9.

    Thanks,
    Graceson

    GracesonGraceson
    Participant

    Hi Long,

    I thought about using the template. However, I am making a plugin so I didn't want to use my child theme.

    Ultimately, I decided to have my PHP functions set a session cookie to indicate success or failure. When my script runs, it uses the value of that cookie to display the proper message, and then destroys the cookie.

    I tried putting the script in rwmb_frontend_after_display_confirmation, however that hook is broken when using AJAX submit on the form. Therefore, I ultimately had to put my script directly in the text of the normal MetaBox confirmation message.

    Do you know if that AJAX bug has been fixed yet? I haven't had a chance to test yet, but the changelog for AIO 1.16.7 doesn't mention anything.

    in reply to: Prevent scroll to form #39808
    GracesonGraceson
    Participant

    Hi Peter,

    I figured out a quick and very dirty fix. I simply deleted r("html, body").animate({scrollTop:a.offset().top-50},200), from frontend-submission.js. This should work until the next update, but it is by no means a proper solution.

    Can you please include this feature, or suggest a more robust work-around?

    Thanks,
    Graceson

    in reply to: Prevent scroll to form #39801
    GracesonGraceson
    Participant

    Hi Peter,

    I know that is the default behavior. Can you share how it works so that I can try to override it?

    Thanks,
    Graceson

    GracesonGraceson
    Participant

    Hi Long,

    Have you heard back from the development team on this issue?

    Thanks,
    Graceson

    GracesonGraceson
    Participant

    Okay, I understand that the page reloads, and so I can not use JS to print out something. However, I am trying to modify the HTML content of the page to display a message using JS per your suggestion. This is what you suggested:

    I think you can use the hook rwmb_frontend_after_process and create some JS code to append the HTML code to the form after processing.

    So if the page reloads, how am I supposed to append the HTML? I could write something to the database and then recall it after the reload, but that seems excessive for a task like this. I'm already using php to send the emails that I want. So, I don't understand how I am supposed to use rwmb_frontend_after_process to run some JS that will alter the HTML of the page.

    Now, my JS function works perfectly inside rwmb_frontend_before_display_confirmation; however, it appears that I can not use rwmb_frontend_before_display_confirmation inside rwmb_frontend_after_process.

    For reference, here is the JS function that I wrote to display the message as desired:

    function subscriptionMessage(status = "none") {
      //Wait until the page exists.
      window.addEventListener('load', function() {
        console.log("subscription validation running");
        const mbValidationMessage = document.querySelector(".rwmb-confirmation");
    
        const message = document.createElement("div");
    
        if (status == "success") {
          message.className = "rwmb-confirmation";
          message.innerHTML = "Thanks for subscribing to our newsletter!";
        } else if (status == "error") {
          message.className = "rwmb-error";
          message.innerHTML = "Uh oh, we could not subscribe you to our newsletter.";
        } else {
          return;
        }
        mbValidationMessage.parentNode.insertBefore(message, mbValidationMessage.nextSibling);
      })
    }
    GracesonGraceson
    Participant

    Hi Long,

    That makes sense. I am working on that solution now; however I am having trouble with that hook still.

    I have written some JS code to display my message, however, that code doesn't seem to run properly when called from rwmb_frontend_after_process.

    To keep things simple, it looks like I can't even log something to the console. For example the following does not work!

    add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
    
    echo '<script>
        console.log("rwmb_frontend_after_process can run JS");
      </script>';
    //WILL NOT LOG TO CONSOLE
    
    $data = [
        'field_1' => 'value 1',
        'field_2' => 'value 2',
        'field 3' => ['one', 'two', 'three'],
    ];
    
    \MetaBox\CustomTable\API::update( $post_id, 'my-custom-table', $data );
    }, 10, 2 );

    Now, I know this code inserts the script properly because I can see the console log if I add die; right after the echo used to insert the script.

    Trying to make the JS run after the DOM is loaded also doesn't work

    echo '<script>
      window.addEventListener(\'load\', function() {
        console.log("rwmb_frontend_after_process can run JS");
      })
      </script>';
    //DOES NOT WORK

    Is there a different hook I need to use, or is there some modification to the JS that will make it work?

Viewing 15 posts - 1 through 15 (of 28 total)