Drupal 7 Module Development - JavaScript confirm before leaving page

By shane
Mon, 2013-02-18 18:23
3 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: 

Comments

Another awesome video! Thanks so much! I've been learning Drupal for about 4 months now, part-time, on my own. I *always* make time to watch your 'Daily Dose' video and have been able to incorporate a lot of it into my first real Drupal site (a custom social network/directory site).

Question:

I see you're using Ubuntu (so am I). What editor are you using? I noticed you have the very useful Drupal API snippets/listing on the right inside your editor.

Thanks again!
Mark

I am using Komodo Edit. I really like it and have been using it for a few years now.

I want to apply this to all nodes of a certain type. Actually of a specific path. I want to apply it to all node/nid/somename. So, nid would represent any nid. I don't do php well, but I tried all that I'm familiar with $&%nid and $&%node. I thought one might work, but I'm guessing there's more to it.

Post new comment