summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Miles2011-07-22 19:44:58 (GMT)
committer Earl Miles2011-07-22 19:44:58 (GMT)
commitca5f88e0b2fbc97e021909852decc820020d611f (patch)
tree4f2445d2219a854be356865403b93e5ef89c6956
parent13a9ec911b1ccba0196f9192d5790ffc9db2b93f (diff)
Issue #1118570: In Views, sometimes modals would hide because of missing -wrapper ids.
-rw-r--r--js/dependent.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/js/dependent.js b/js/dependent.js
index 9ed0a32..1324f9f 100644
--- a/js/dependent.js
+++ b/js/dependent.js
@@ -54,6 +54,8 @@
// Iterate through all relationships
for (id in Drupal.settings.CTools.dependent) {
+ // Test to make sure the id even exists; this helps clean up multiple
+ // AJAX calls with multiple forms.
// Drupal.CTools.dependent.activeBindings[id] is a boolean,
// whether the binding is active or not. Defaults to no.
@@ -87,6 +89,10 @@
}
var getValue = function(item, trigger) {
+ if ($(trigger).size() == 0) {
+ return null;
+ }
+
if (item.substring(0, 6) == 'radio:') {
var val = $(trigger + ':checked').val();
}
@@ -115,14 +121,21 @@
var changeTrigger = function() {
var val = getValue(bind_id, trigger_id);
+ if (val == null) {
+ return;
+ }
+
for (i in Drupal.CTools.dependent.bindings[bind_id]) {
var id = Drupal.CTools.dependent.bindings[bind_id][i];
-
// Fix numerous errors
if (typeof id != 'string') {
continue;
}
+ if (!$('#' + id).size()) {
+ console.log(id + ' does not exist');
+ }
+
// This bit had to be rewritten a bit because two properties on the
// same set caused the counter to go up and up and up.
if (!Drupal.CTools.dependent.activeBindings[id]) {
@@ -143,6 +156,16 @@
var object = $('#' + id + '-wrapper');
if (!object.size()) {
+ // Some elements can't use the parent() method or they can
+ // damage things. They are guaranteed to have wrappers but
+ // only if dependent.inc provided them. This check prevents
+ // problems when multiple AJAX calls cause settings to build
+ // up.
+ var $original = $('#' + id);
+ if ($original.is('fieldset') || $original.is('textarea')) {
+ continue;
+ }
+
object = $('#' + id).parent();
}