Skip to content
Snippets Groups Projects
Commit 8b7c21ee authored by Matthew Radcliffe's avatar Matthew Radcliffe
Browse files

Issue #2706517 by mradcliffe: Make JQuery 1.9 fix backwards-compatible.

parent 115207a4
No related branches found
No related tags found
No related merge requests found
//$Id$
/**
* @file
* cck_select_other javascript file
......@@ -8,6 +7,8 @@
Drupal.behaviors.cckSelectOther = {
attach: function (context, settings) {
var ActionBind = this.getActionBind();
// Prevent errors
if (typeof settings.CCKSelectOther != 'object') return;
......@@ -22,18 +23,31 @@
$(document).ready( function() {
// We need to go up further up the element chain to work around 'add another item'
$('select#edit-' + select_id).change(function() {
$('select#edit-' + select_id).bind(ActionBind, function() {
// Add parent() to hide input wrapper
$(this).children(':selected').each(function() {
if($(this).val() == 'other'){
if($(this).val() === 'other'){
$('input#edit-' + text_id).parent().show();
} else{
$('input#edit-' + text_id).parent().hide();
}
});
}).trigger('change');
}).trigger(ActionBind);
});
});
},
/**
* Provides a backwards-compatible way of supporting Drupal 7 core jQuery,
* and contemporary versions of jQuery without browser detection support.
*
* @returns {string}
*/
getActionBind: function() {
var action = 'change';
if (undefined !== $.browser && $.browser.msie === true) {
action = 'click';
}
return action;
}
}
})(jQuery);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment