mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Only initialise chosen elements when visible.
This commit is contained in:
parent
b38735d536
commit
2503e481ff
@ -20,16 +20,20 @@ jQuery.noConflict();
|
|||||||
|
|
||||||
// apply an select element only when it is ready, ie. when it is rendered into a template
|
// 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.
|
// with css applied and got a width value.
|
||||||
var applyChosen = function(el){
|
var applyChosen = function(el) {
|
||||||
if(el.outerWidth()){
|
if(el.is(':visible')) {
|
||||||
el.chosen({
|
el.addClass('has-chzn').chosen({
|
||||||
'disable_search_threshold' : 20,
|
allow_single_deselect: true,
|
||||||
'allow_single_deselect': true
|
disable_search_threshold: 20
|
||||||
}).addClass("has-chzn");
|
});
|
||||||
// Copy over title attribute if required
|
|
||||||
if(el.attr('title')) el.siblings('.chzn-container').attr('title', el.attr('title'));
|
var title = el.prop('title')
|
||||||
|
|
||||||
|
if(title) {
|
||||||
|
el.siblings('.chzn-container').prop('title', title);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setTimeout(function() {applyChosen(el);},500);
|
setTimeout(function() { applyChosen(el); }, 500);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user