Needs review
Project:
Inline Messages
Version:
6.x-1.7
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Jul 2011 at 18:14 UTC
Updated:
24 Oct 2012 at 12:39 UTC
The JavaScript used to move inline messages should use Drupal.behaviors instead of $(document).ready(). See http://drupal.org/node/304258 for a detailed explanation of why this is important.
The short version is:
* It is a Drupal standard.
* Messages won't be moved inline if they are inserted into the page asynchronously.
I've attached a patch that fixes this. It also fixes a few other problems with the JavaScript. The main problem was that the code seemed to be mixing PHP and JavaScript. For example, declaring variables like this:
$form_id = $('form#' + Drupal.settings.form_submitted);
instead of like this:
var form_id = $('form#' + Drupal.settings.form_submitted);
| Comment | File | Size | Author |
|---|---|---|---|
| javascript_behaviors.patch | 1.95 KB | jtsnow |
Comments
Comment #1
ain commentedI do disagree Re mixing PHP with JavaScript. I use the exact same convention in jQuery in such circumstances and I believe it's completely fine.
Comment #2
jtsnow commentedYes, I have since learned that prefixing JavaScript variables with a dollar sign is a convention for naming variables that contain Drupal objects. The Drupal JavaScript coding standards do not specify a preference on this and some code in Drupal 7 core follows the convention, so it is legitimate.
However, the coding standards do say "All variables should be declared with var before they are used and should only be declared once. "
Comment #3
jtsnow commentedYes, I have since learned that prefixing JavaScript variables with a dollar sign is a convention for naming variables that contain Drupal objects. The Drupal JavaScript coding standards do not specify a preference on this and some code in Drupal 7 core follows the convention, so it is legitimate.
However, the coding standards do say "All variables should be declared with var before they are used and should only be declared once. "
Comment #3.0
jtsnow commentedUpdating documentation link.