Don't try to access itemsView until loaded in citation dialogs

This commit is contained in:
Dan Stillman 2016-04-25 00:33:57 -04:00
parent 7bc80d1f32
commit a605fe1cff
2 changed files with 10 additions and 4 deletions

View file

@ -664,7 +664,9 @@ var Zotero_Citation_Dialog = new function () {
_multipleSourceButton.disabled = false;
}
} else {
_acceptButton.disabled = !itemsView.getSelectedItems().length; // treeview from xpcom/itemTreeView.js
collectionsView.addEventListener('load', () => {
_acceptButton.disabled = !itemsView.getSelectedItems().length;
});
}
}

View file

@ -32,8 +32,7 @@ var io;
* io - used for input/output (dataOut is list of item IDs)
* sourcesOnly - whether only sources should be shown in the window
*/
function doLoad()
{
var doLoad = Zotero.Promise.coroutine(function* () {
// Set font size from pref
var sbc = document.getElementById('zotero-select-items-container');
Zotero.setFontSize(sbc);
@ -47,10 +46,15 @@ function doLoad()
// Don't show Commons when citing
collectionsView.hideSources = ['duplicates', 'trash', 'feeds'];
document.getElementById('zotero-collections-tree').view = collectionsView;
var deferred = Zotero.Promise.defer();
collectionsView.addEventListener('load', () => deferred.resolve());
yield deferred.promise;
if(io.select) itemsView.selectItem(io.select);
Zotero.updateQuickSearchBox(document);
}
});
function doUnload()
{