Skip to content
Snippets Groups Projects

Improved ref switcher dropdown performance

Merged Phil Hughes requested to merge ref-switcher-perf into master
2 files
+ 21
7
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -63,7 +63,8 @@
@@ -63,7 +63,8 @@
return $.ajax({
return $.ajax({
url: $dropdown.data('refs-url'),
url: $dropdown.data('refs-url'),
data: {
data: {
ref: $dropdown.data('ref')
ref: $dropdown.data('ref'),
 
search: term
},
},
dataType: "json"
dataType: "json"
}).done(function(refs) {
}).done(function(refs) {
@@ -72,16 +73,26 @@
@@ -72,16 +73,26 @@
},
},
selectable: true,
selectable: true,
filterable: true,
filterable: true,
 
filterRemote: true,
filterByText: true,
filterByText: true,
fieldName: $dropdown.data('field-name'),
fieldName: $dropdown.data('field-name'),
renderRow: function(ref) {
renderRow: function(ref) {
var link;
var li = document.createElement('li');
 
if (ref.header != null) {
if (ref.header != null) {
return $('<li />').addClass('dropdown-header').text(ref.header);
li.className = 'dropdown-header';
 
li.textContent = ref.header;
} else {
} else {
link = $('<a />').attr('href', '#').addClass(ref === selected ? 'is-active' : '').text(ref).attr('data-ref', ref);
var link = document.createElement('a');
return $('<li />').append(link);
link.href = '#';
 
link.className = ref.name === selected ? 'is-active' : '';
 
link.textContent = ref.name;
 
link.dataset.ref = ref.name;
 
 
li.appendChild(link);
}
}
 
 
return li;
},
},
id: function(obj, $el) {
id: function(obj, $el) {
return $el.attr('data-ref');
return $el.attr('data-ref');
Loading