[Rt-commit] rt branch, 4.2/cascaded-non-select, created. rt-4.2.3-14-g799a9e1
Alex Vandiver
alexmv at bestpractical.com
Tue Mar 4 14:59:46 EST 2014
The branch, 4.2/cascaded-non-select has been created
at 799a9e174164b30e33700999129f2052fd6e64de (commit)
- Log -----------------------------------------------------------------
commit 799a9e174164b30e33700999129f2052fd6e64de
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue Mar 4 14:50:56 2014 -0500
Use .filter() to protect against jQuery's lack of escaping
Similar to 69bad2a0, this works around the inability to guaranteedly
escape characters in jQuery attribute selectors. For example, this
would cause categories with spaces or . in them to display no
sub-options when those options were rendered as a list.
Instead of shoving an unknown set of characters after the starts-with
selector, use .filter() to iterate over the possibilities and check for
starts-with using .indexOf().
diff --git a/share/static/js/cascaded.js b/share/static/js/cascaded.js
index c5ea64a..0593466 100644
--- a/share/static/js/cascaded.js
+++ b/share/static/js/cascaded.js
@@ -21,7 +21,10 @@ function filter_cascade_by_id (id, vals, is_hierarchical) {
jQuery(element).find('div[data-name=]').show().find('input').prop('disabled', false);
jQuery(element).find('div.none').show().find('input').prop('disabled',false);
for ( var j = 0; j < vals.length; j++ ) {
- jQuery(element).find('div[data-name^=' + vals[j] + ']').show().find('input').prop('disabled', false);
+ var match = jQuery(element).find('div[data-name]').filter(function(){
+ return jQuery(this).data('name').indexOf(vals[j]) == 0
+ });
+ match.show().find('input').prop('disabled', false);
}
}
}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list