mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02: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
|
||||
// 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);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user