AnsweredAssumed Answered

enhanced bookmark widget - load bookmarks from saved json

Question asked by K0831901 on Jul 5, 2017
Latest reply on Jul 12, 2017 by K0831901

I just started to convert my flex web application into a JavaScript one and I am having some difficulty with a piece of functionality I am trying to add to the Enhanced Bookmark Widget - namely to allow the user to load a list of bookmarks via a saved JSON file.


I have added a 'Load' button and when it is clicked it reads in the user's chosen file but then I am stuck. Having tried various things, I think what I need to do is something like the below code. Specifically, I haven't got the hang of passing my result out to the new BookmarkListView - the result just becomes 'undefined'. Can anyone point me in the right direction as to how I need to reference as mybookmarkarray to make it the result of the FileReader?

    _onLoadBtnClicked: function() {
      var file = fileInput.files[0];
              var reader = new FileReader();
              reader.onload = function(e){
                result = reader.result;
                catch (e){
                    alert("This is not a valid Bookmarks file")
                //I checked the result and it is good but...
                //How do I pass result from here

              this.bookmarkListView = new BookmarkListView({
                mybookmarkarray: //to here
                eBookmarkWidget: this,
                config: this.config,
                nls: this.nls

Thanks for any help.