Why changes are not saved in file in SVG-Edit?












0















function FileLoad(file) {
svgEditor.loadFromURL(file);
var svg = document.getElementById("svgID");
code continues....
}


I am trying to manipulate a svg after it gets load.



But the code is not further executed,neither it is shown in developer tool



I am using SVG-Edit toool.










share|improve this question





























    0















    function FileLoad(file) {
    svgEditor.loadFromURL(file);
    var svg = document.getElementById("svgID");
    code continues....
    }


    I am trying to manipulate a svg after it gets load.



    But the code is not further executed,neither it is shown in developer tool



    I am using SVG-Edit toool.










    share|improve this question



























      0












      0








      0








      function FileLoad(file) {
      svgEditor.loadFromURL(file);
      var svg = document.getElementById("svgID");
      code continues....
      }


      I am trying to manipulate a svg after it gets load.



      But the code is not further executed,neither it is shown in developer tool



      I am using SVG-Edit toool.










      share|improve this question
















      function FileLoad(file) {
      svgEditor.loadFromURL(file);
      var svg = document.getElementById("svgID");
      code continues....
      }


      I am trying to manipulate a svg after it gets load.



      But the code is not further executed,neither it is shown in developer tool



      I am using SVG-Edit toool.







      javascript svg






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 6:59









      Krupesh Kotecha

      2,07311136




      2,07311136










      asked Nov 16 '18 at 6:41









      ShahidShahid

      318




      318
























          1 Answer
          1






          active

          oldest

          votes


















          1














          svgEditor.loadFromURL() returns a Promise. Loading, by its nature, is always an asynchronuous operation. You need to wait until it is done:



          function FileLoad(file) {
          svgEditor.loadFromURL(file).then(function () {
          var svg = document.getElementById("svgID");
          // code continues....
          }, function (error) {
          // load error handling
          });
          }


          From the naming of your function it looks as if you use it for instantiating an object. However you use the FileLoad function, notice that the SVG content will not be available synchronuously, but only after the promise has resolved. In the case of calling it with new, a possible pattern could look like this (the callback function containing everything you do with the instantiated object):



          function FileLoad(file, callback) {
          svgEditor.loadFromURL(file).then(function () {
          var svg = document.getElementById("svgID");
          code continues....
          }, function (error) {
          // load error handling
          }).then(callback.bind(this));
          }

          fileInstance = new FileLoad(url, callback);


          Edit: The function changed its signature with version 4.0.0. For version 3.2.0 and older, you need to pass a callback function in a config object:



          function FileLoad(file) {
          svgEditor.loadFromURL(file, {
          callback: function (success) {
          if (success) {
          var svg = document.getElementById("svgID");
          // code continues....
          } else {
          // load error handling
          }
          }
          });
          }





          share|improve this answer


























          • It gives me the error :Cannot read property 'then' of undefined

            – Shahid
            Nov 17 '18 at 8:29











          • Which line, exactly?

            – ccprog
            Nov 17 '18 at 16:00











          • svgEditor.loadFromURL(file).then(function () { :this line

            – Shahid
            Nov 17 '18 at 16:13











          • isn't your svgEditor variable an instance of the SVGEditor class? Which version are you runing?

            – ccprog
            Nov 17 '18 at 16:28











          • yes..I dnt know about the version

            – Shahid
            Nov 17 '18 at 16:50












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332701%2fwhy-changes-are-not-saved-in-file-in-svg-edit%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          svgEditor.loadFromURL() returns a Promise. Loading, by its nature, is always an asynchronuous operation. You need to wait until it is done:



          function FileLoad(file) {
          svgEditor.loadFromURL(file).then(function () {
          var svg = document.getElementById("svgID");
          // code continues....
          }, function (error) {
          // load error handling
          });
          }


          From the naming of your function it looks as if you use it for instantiating an object. However you use the FileLoad function, notice that the SVG content will not be available synchronuously, but only after the promise has resolved. In the case of calling it with new, a possible pattern could look like this (the callback function containing everything you do with the instantiated object):



          function FileLoad(file, callback) {
          svgEditor.loadFromURL(file).then(function () {
          var svg = document.getElementById("svgID");
          code continues....
          }, function (error) {
          // load error handling
          }).then(callback.bind(this));
          }

          fileInstance = new FileLoad(url, callback);


          Edit: The function changed its signature with version 4.0.0. For version 3.2.0 and older, you need to pass a callback function in a config object:



          function FileLoad(file) {
          svgEditor.loadFromURL(file, {
          callback: function (success) {
          if (success) {
          var svg = document.getElementById("svgID");
          // code continues....
          } else {
          // load error handling
          }
          }
          });
          }





          share|improve this answer


























          • It gives me the error :Cannot read property 'then' of undefined

            – Shahid
            Nov 17 '18 at 8:29











          • Which line, exactly?

            – ccprog
            Nov 17 '18 at 16:00











          • svgEditor.loadFromURL(file).then(function () { :this line

            – Shahid
            Nov 17 '18 at 16:13











          • isn't your svgEditor variable an instance of the SVGEditor class? Which version are you runing?

            – ccprog
            Nov 17 '18 at 16:28











          • yes..I dnt know about the version

            – Shahid
            Nov 17 '18 at 16:50
















          1














          svgEditor.loadFromURL() returns a Promise. Loading, by its nature, is always an asynchronuous operation. You need to wait until it is done:



          function FileLoad(file) {
          svgEditor.loadFromURL(file).then(function () {
          var svg = document.getElementById("svgID");
          // code continues....
          }, function (error) {
          // load error handling
          });
          }


          From the naming of your function it looks as if you use it for instantiating an object. However you use the FileLoad function, notice that the SVG content will not be available synchronuously, but only after the promise has resolved. In the case of calling it with new, a possible pattern could look like this (the callback function containing everything you do with the instantiated object):



          function FileLoad(file, callback) {
          svgEditor.loadFromURL(file).then(function () {
          var svg = document.getElementById("svgID");
          code continues....
          }, function (error) {
          // load error handling
          }).then(callback.bind(this));
          }

          fileInstance = new FileLoad(url, callback);


          Edit: The function changed its signature with version 4.0.0. For version 3.2.0 and older, you need to pass a callback function in a config object:



          function FileLoad(file) {
          svgEditor.loadFromURL(file, {
          callback: function (success) {
          if (success) {
          var svg = document.getElementById("svgID");
          // code continues....
          } else {
          // load error handling
          }
          }
          });
          }





          share|improve this answer


























          • It gives me the error :Cannot read property 'then' of undefined

            – Shahid
            Nov 17 '18 at 8:29











          • Which line, exactly?

            – ccprog
            Nov 17 '18 at 16:00











          • svgEditor.loadFromURL(file).then(function () { :this line

            – Shahid
            Nov 17 '18 at 16:13











          • isn't your svgEditor variable an instance of the SVGEditor class? Which version are you runing?

            – ccprog
            Nov 17 '18 at 16:28











          • yes..I dnt know about the version

            – Shahid
            Nov 17 '18 at 16:50














          1












          1








          1







          svgEditor.loadFromURL() returns a Promise. Loading, by its nature, is always an asynchronuous operation. You need to wait until it is done:



          function FileLoad(file) {
          svgEditor.loadFromURL(file).then(function () {
          var svg = document.getElementById("svgID");
          // code continues....
          }, function (error) {
          // load error handling
          });
          }


          From the naming of your function it looks as if you use it for instantiating an object. However you use the FileLoad function, notice that the SVG content will not be available synchronuously, but only after the promise has resolved. In the case of calling it with new, a possible pattern could look like this (the callback function containing everything you do with the instantiated object):



          function FileLoad(file, callback) {
          svgEditor.loadFromURL(file).then(function () {
          var svg = document.getElementById("svgID");
          code continues....
          }, function (error) {
          // load error handling
          }).then(callback.bind(this));
          }

          fileInstance = new FileLoad(url, callback);


          Edit: The function changed its signature with version 4.0.0. For version 3.2.0 and older, you need to pass a callback function in a config object:



          function FileLoad(file) {
          svgEditor.loadFromURL(file, {
          callback: function (success) {
          if (success) {
          var svg = document.getElementById("svgID");
          // code continues....
          } else {
          // load error handling
          }
          }
          });
          }





          share|improve this answer















          svgEditor.loadFromURL() returns a Promise. Loading, by its nature, is always an asynchronuous operation. You need to wait until it is done:



          function FileLoad(file) {
          svgEditor.loadFromURL(file).then(function () {
          var svg = document.getElementById("svgID");
          // code continues....
          }, function (error) {
          // load error handling
          });
          }


          From the naming of your function it looks as if you use it for instantiating an object. However you use the FileLoad function, notice that the SVG content will not be available synchronuously, but only after the promise has resolved. In the case of calling it with new, a possible pattern could look like this (the callback function containing everything you do with the instantiated object):



          function FileLoad(file, callback) {
          svgEditor.loadFromURL(file).then(function () {
          var svg = document.getElementById("svgID");
          code continues....
          }, function (error) {
          // load error handling
          }).then(callback.bind(this));
          }

          fileInstance = new FileLoad(url, callback);


          Edit: The function changed its signature with version 4.0.0. For version 3.2.0 and older, you need to pass a callback function in a config object:



          function FileLoad(file) {
          svgEditor.loadFromURL(file, {
          callback: function (success) {
          if (success) {
          var svg = document.getElementById("svgID");
          // code continues....
          } else {
          // load error handling
          }
          }
          });
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 17 '18 at 16:42

























          answered Nov 16 '18 at 14:54









          ccprogccprog

          9,93521128




          9,93521128













          • It gives me the error :Cannot read property 'then' of undefined

            – Shahid
            Nov 17 '18 at 8:29











          • Which line, exactly?

            – ccprog
            Nov 17 '18 at 16:00











          • svgEditor.loadFromURL(file).then(function () { :this line

            – Shahid
            Nov 17 '18 at 16:13











          • isn't your svgEditor variable an instance of the SVGEditor class? Which version are you runing?

            – ccprog
            Nov 17 '18 at 16:28











          • yes..I dnt know about the version

            – Shahid
            Nov 17 '18 at 16:50



















          • It gives me the error :Cannot read property 'then' of undefined

            – Shahid
            Nov 17 '18 at 8:29











          • Which line, exactly?

            – ccprog
            Nov 17 '18 at 16:00











          • svgEditor.loadFromURL(file).then(function () { :this line

            – Shahid
            Nov 17 '18 at 16:13











          • isn't your svgEditor variable an instance of the SVGEditor class? Which version are you runing?

            – ccprog
            Nov 17 '18 at 16:28











          • yes..I dnt know about the version

            – Shahid
            Nov 17 '18 at 16:50

















          It gives me the error :Cannot read property 'then' of undefined

          – Shahid
          Nov 17 '18 at 8:29





          It gives me the error :Cannot read property 'then' of undefined

          – Shahid
          Nov 17 '18 at 8:29













          Which line, exactly?

          – ccprog
          Nov 17 '18 at 16:00





          Which line, exactly?

          – ccprog
          Nov 17 '18 at 16:00













          svgEditor.loadFromURL(file).then(function () { :this line

          – Shahid
          Nov 17 '18 at 16:13





          svgEditor.loadFromURL(file).then(function () { :this line

          – Shahid
          Nov 17 '18 at 16:13













          isn't your svgEditor variable an instance of the SVGEditor class? Which version are you runing?

          – ccprog
          Nov 17 '18 at 16:28





          isn't your svgEditor variable an instance of the SVGEditor class? Which version are you runing?

          – ccprog
          Nov 17 '18 at 16:28













          yes..I dnt know about the version

          – Shahid
          Nov 17 '18 at 16:50





          yes..I dnt know about the version

          – Shahid
          Nov 17 '18 at 16:50




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332701%2fwhy-changes-are-not-saved-in-file-in-svg-edit%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Danny Elfman

          Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues