annotations are loaded asynchronously: dont fire select event before they are loaded.

This commit is contained in:
j 2014-12-26 12:08:35 +00:00
parent acbb56da65
commit 4aba1474d6
2 changed files with 30 additions and 30 deletions

View file

@ -342,12 +342,21 @@ Ox.AnnotationFolder = function(options, self) {
? self.$outer : that.$content
);
self.loaded = false;
setTimeout(function() {
self.$annotations.options({
items: self.annotations,
placeholder: getPlaceholder(),
selected: self.options.selected
});
self.loaded = true;
if (self.options.selected) {
// need timeout in order to trigger events
if (self.options.collapsed) {
self.$panel.options({collapsed: false});
}
selectAnnotation({id: self.options.selected});
};
});
[
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
@ -363,13 +372,6 @@ Ox.AnnotationFolder = function(options, self) {
});
});
self.options.selected && setTimeout(function() {
// need timeout in order to trigger events
if (self.options.collapsed) {
self.$panel.options({collapsed: false});
}
selectAnnotation({id: self.options.selected});
}, 0);
showWarnings();
@ -537,6 +539,7 @@ Ox.AnnotationFolder = function(options, self) {
}
function selectAnnotation(data) {
if (self.loaded) {
var item = Ox.getObjectById(self.options.items, data.id);
self.options.selected = item ? data.id : '';
if (self.widget) {
@ -558,6 +561,7 @@ Ox.AnnotationFolder = function(options, self) {
layer: self.options.id
} : {}));
}
}
function showWarnings() {
if (self.widget && self.options.items.length) {

View file

@ -139,10 +139,6 @@ Ox.AnnotationPanel = function(options, self) {
})
);
self.options.selected && getFolder(self.options.selected) && scrollToSelected(
getFolder(self.options.selected).options('type')
);
function getAnnotation(annotationId) {
var found = false, annotation;
Ox.forEach(self.options.layers, function(layer, i) {