I have a menu item that shows up on one of my nodes and when pressed it will trigger a somewhat long process. I would like to make it so that the user is not tempted to press the menu button again but I can't quite figure out how to do that. Is there a good way to put an overlay over the Drupal window to explain that the process will take some time and prevent another click? If not, would it be possible to show an alert dialog from the menu callback, warning the user this will take some time.
-
Is your menu using Drupal's AJAX?– Leolando TanCommented Apr 3, 2015 at 5:10
-
If you want to use AJAX, Drupal already adds the progress-disabled class so I guess the link is covered already. You can try the Chaos Tools AJAX Demo module.– Leolando TanCommented Apr 3, 2015 at 5:38
Add a comment
|
2 Answers
For long tasks you should use Drupal's Batch API. It takes a bit to learn, but has these benefits.
- The user will be taken to a separate page with a progress bar.
- You can display a custom message explaining what you are doing.
- If you can break your task into discrete chunks that can be performed in separate requests that will ensure that you won't run into any php timeout issues and the users will see their progress.
For example, during Drupal setup you see the following batch process:
This module is matching your requirement https://www.drupal.org/project/jquery_loadinganimation.