Forum Replies Created
-
AuthorPosts
-
Graceson
ParticipantHi 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 settingallow_scroll="false"disables all scrolling behavior as expected.The hotfix they just released makes everything work perfectly!
Graceson
ParticipantHi,
I don't think you are quite right since I have found one possibility.
Turns out you can use
composer config --global --editorto edit the local configuration. That way, you don't have to have the license key included in composer.json.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.
Graceson
ParticipantHi 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
trueis 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 featureallow_scroll="true"was the default behavior and I don't think you developers would want to introduce a breaking change. Also, if settingallow_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.
Graceson
ParticipantMaking 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?
Graceson
ParticipantI 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.
Graceson
ParticipantSorry, that was a typo on my end.
I saw no difference when
allow_scroll="false"so I was testing to see ifallow_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"?Graceson
ParticipantHi 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.
Graceson
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,
GracesonJanuary 4, 2023 at 1:22 AM in reply to: Second validation message with rwmb_frontend_after_display_confirmation #40110Graceson
ParticipantHi 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,
GracesonDecember 15, 2022 at 7:16 AM in reply to: Second validation message with rwmb_frontend_after_display_confirmation #39809Graceson
ParticipantHi 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.
Graceson
ParticipantHi 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,
GracesonGraceson
ParticipantHi Peter,
I know that is the default behavior. Can you share how it works so that I can try to override it?
Thanks,
GracesonNovember 12, 2022 at 7:21 AM in reply to: Ajax interfering with using get_the_ID() inside rwmb_frontend_after_process #39084Graceson
ParticipantHi Long,
Have you heard back from the development team on this issue?
Thanks,
GracesonOctober 20, 2022 at 12:05 AM in reply to: Second validation message with rwmb_frontend_after_display_confirmation #38754Graceson
ParticipantOkay, 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_processand 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_processto 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 userwmb_frontend_before_display_confirmationinsiderwmb_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); }) }October 19, 2022 at 12:46 AM in reply to: Second validation message with rwmb_frontend_after_display_confirmation #38743Graceson
ParticipantHi 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 WORKIs there a different hook I need to use, or is there some modification to the JS that will make it work?
-
AuthorPosts