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