Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Only initialise chosen elements when visible.

  • Loading branch information...
commit 2503e481ff600971b247bd2f24fc030cf023c148 1 parent b38735d
@ajshort ajshort authored chillu committed
Showing with 13 additions and 9 deletions.
  1. +13 −9 admin/javascript/LeftAndMain.js
View
22 admin/javascript/LeftAndMain.js
@@ -20,16 +20,20 @@ jQuery.noConflict();
// apply an select element only when it is ready, ie. when it is rendered into a template
// with css applied and got a width value.
- var applyChosen = function(el){
- if(el.outerWidth()){
- el.chosen({
- 'disable_search_threshold' : 20,
- 'allow_single_deselect': true
- }).addClass("has-chzn");
- // Copy over title attribute if required
- if(el.attr('title')) el.siblings('.chzn-container').attr('title', el.attr('title'));
+ var applyChosen = function(el) {
+ if(el.is(':visible')) {
+ el.addClass('has-chzn').chosen({
+ allow_single_deselect: true,
+ disable_search_threshold: 20
+ });
+
+ var title = el.prop('title')
+
+ if(title) {
+ el.siblings('.chzn-container').prop('title', title);
+ }
} else {
- setTimeout(function() {applyChosen(el);},500);
+ setTimeout(function() { applyChosen(el); }, 500);
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.