Drupal 7 Module Development - JavaScript confirm before leaving page

By shane
Mon, 2013-02-18 18:23
comments
Daily Dose of Drupal Episode #111

Share with Others

Learning module development in Drupal is not easy, but this Daily Dose of Drupal episode provides a very simple but practical module development video tutorial to use when learning about Drupal Module development. If you have a complex form on your Drupal websites, whether it is a Node creation form or perhaps even a webform, you may want to warn users before they navigate away from the page. This can help inform users that if they navigate away from the page before submitting the form, they may lose the contents of the form.

Note: In the uploaded module I added an extra feature that makes sure the confirmation form does not show up when submitting the form. I did not cover this in the video.

In this episode you will learn:

  • How to create a simple Drupal 7 module
  • How to create a Drupal 7 .info file
  • How to create a Drupal 7 .module file
  • How to use the Drupal 7 hook_init() function
  • How to use the drupal_add_js() function to add inline JavaScript
  • How to use the current_path() function to get the current Drupal system path

Thanks to Drupalize.me for sponsoring this episode.

File attachments: