vis.js removing whole graph when deleting single nodeWhen to use double or single quotes in JavaScript?How to find event listeners on a DOM node when debugging or from the JavaScript code?Remove all child elements of a DOM node in JavaScriptFiltering disconnected nodes in vis.jsHow to retrieve data from api res.send?vis.js node placement when physics is disabledincrease node size vis.jsVis.js not showing graph when many nodes are addedHow to extract a title of nodes in Network graph in Vis.jsconsole logging data with ajax post method

New coworker has strange workplace requirements - how should I deal with them?

What are ways to record who took the pictures if a camera is used by multiple people?

Sum and average calculator

Squares inside a square

Can two aircraft be allowed to stay on the same runway at the same time?

Can UV radiation be safe for the skin?

Fishing from underwater domes

How could reincarnation magic be limited to prevent overuse?

What is the definition of belonging in axiomatic set theory?

Create a list of snaking numbers under 50,000

Why don't "echo -e" commands seem to produce the right output?

Is it good practice to speed up and slow down where not written in a song?

Should a TA point out a professor's mistake while attending their lecture?

Ways you can end up paying interest on a credit card if you pay the full amount back in due time

How do I get my neighbour to stop disturbing with loud music?

Where should I draw the line on follow up questions from previous employer

Colored grid with coordinates on all sides?

Quick Tilepaint Puzzles: Corridors and Corners

Can a system of three stars exist?

Is Chuck the Evil Sandwich Making Guy's head actually a sandwich?

Ideas behind the 8.Bd3 line in the 4.Ng5 Two Knights Defense

Does the telecom provider need physical access to the SIM card to clone it?

I was given someone else's visa, stamped in my passport

Four day weekend?



vis.js removing whole graph when deleting single node


When to use double or single quotes in JavaScript?How to find event listeners on a DOM node when debugging or from the JavaScript code?Remove all child elements of a DOM node in JavaScriptFiltering disconnected nodes in vis.jsHow to retrieve data from api res.send?vis.js node placement when physics is disabledincrease node size vis.jsVis.js not showing graph when many nodes are addedHow to extract a title of nodes in Network graph in Vis.jsconsole logging data with ajax post method






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm trying to delete a node from a vis.js graph. When the function is applied, instead of the node and its outgoing edges being deleted the entire graph gets erased. I want the changes to be kept intact when the page gets refreshed. The calls related to this are deleteNode (in index.html) and app.delete (in index.js).



index.html:



var deleteNode = function(data, callback)
$.ajax(
method: "delete",
url: "/api/node",
data: node: data.nodes[0] ,
success: function(result)
callback(result);

)
;


index.js:



app.delete("/api/node", function(req, res)
var deleteNode = req.body.node;
var deleteResult =
nodes:[],
edges: []
;

var updatedNodes = _.filter(data.nodes, function(node)
var keep = (node.id !== deleteNode);
if(!keep)
deleteResult.nodes.push(node);

return keep;
);

var updatedEdges = _.filter(data.edges, function(edge)
var keep = (edge.from !== deleteNode) );

data.nodes = updatedNodes;
data.edges = updatedEdges;

res.send(deleteResult).end();
);









share|improve this question
































    0















    I'm trying to delete a node from a vis.js graph. When the function is applied, instead of the node and its outgoing edges being deleted the entire graph gets erased. I want the changes to be kept intact when the page gets refreshed. The calls related to this are deleteNode (in index.html) and app.delete (in index.js).



    index.html:



    var deleteNode = function(data, callback)
    $.ajax(
    method: "delete",
    url: "/api/node",
    data: node: data.nodes[0] ,
    success: function(result)
    callback(result);

    )
    ;


    index.js:



    app.delete("/api/node", function(req, res)
    var deleteNode = req.body.node;
    var deleteResult =
    nodes:[],
    edges: []
    ;

    var updatedNodes = _.filter(data.nodes, function(node)
    var keep = (node.id !== deleteNode);
    if(!keep)
    deleteResult.nodes.push(node);

    return keep;
    );

    var updatedEdges = _.filter(data.edges, function(edge)
    var keep = (edge.from !== deleteNode) );

    data.nodes = updatedNodes;
    data.edges = updatedEdges;

    res.send(deleteResult).end();
    );









    share|improve this question




























      0












      0








      0








      I'm trying to delete a node from a vis.js graph. When the function is applied, instead of the node and its outgoing edges being deleted the entire graph gets erased. I want the changes to be kept intact when the page gets refreshed. The calls related to this are deleteNode (in index.html) and app.delete (in index.js).



      index.html:



      var deleteNode = function(data, callback)
      $.ajax(
      method: "delete",
      url: "/api/node",
      data: node: data.nodes[0] ,
      success: function(result)
      callback(result);

      )
      ;


      index.js:



      app.delete("/api/node", function(req, res)
      var deleteNode = req.body.node;
      var deleteResult =
      nodes:[],
      edges: []
      ;

      var updatedNodes = _.filter(data.nodes, function(node)
      var keep = (node.id !== deleteNode);
      if(!keep)
      deleteResult.nodes.push(node);

      return keep;
      );

      var updatedEdges = _.filter(data.edges, function(edge)
      var keep = (edge.from !== deleteNode) );

      data.nodes = updatedNodes;
      data.edges = updatedEdges;

      res.send(deleteResult).end();
      );









      share|improve this question
















      I'm trying to delete a node from a vis.js graph. When the function is applied, instead of the node and its outgoing edges being deleted the entire graph gets erased. I want the changes to be kept intact when the page gets refreshed. The calls related to this are deleteNode (in index.html) and app.delete (in index.js).



      index.html:



      var deleteNode = function(data, callback)
      $.ajax(
      method: "delete",
      url: "/api/node",
      data: node: data.nodes[0] ,
      success: function(result)
      callback(result);

      )
      ;


      index.js:



      app.delete("/api/node", function(req, res)
      var deleteNode = req.body.node;
      var deleteResult =
      nodes:[],
      edges: []
      ;

      var updatedNodes = _.filter(data.nodes, function(node)
      var keep = (node.id !== deleteNode);
      if(!keep)
      deleteResult.nodes.push(node);

      return keep;
      );

      var updatedEdges = _.filter(data.edges, function(edge)
      var keep = (edge.from !== deleteNode) );

      data.nodes = updatedNodes;
      data.edges = updatedEdges;

      res.send(deleteResult).end();
      );






      javascript jquery ajax api vis.js






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 2:19









      ottomeister

      3,4572 gold badges15 silver badges21 bronze badges




      3,4572 gold badges15 silver badges21 bronze badges










      asked Mar 28 at 0:10









      Julian LanksteadJulian Lankstead

      1




      1

























          1 Answer
          1






          active

          oldest

          votes


















          0















          Are you sure that your logic is correct? That is the first thing I would check here. In particular, I see that your 'delete' method seems to be returning the 'deleteResult' variable, which is going to have probably all the nodes that you deleted as a consequence of the API call. Perhaps you wanted to return the 'data' variable instead?






          share|improve this answer
























            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%2f55388323%2fvis-js-removing-whole-graph-when-deleting-single-node%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









            0















            Are you sure that your logic is correct? That is the first thing I would check here. In particular, I see that your 'delete' method seems to be returning the 'deleteResult' variable, which is going to have probably all the nodes that you deleted as a consequence of the API call. Perhaps you wanted to return the 'data' variable instead?






            share|improve this answer





























              0















              Are you sure that your logic is correct? That is the first thing I would check here. In particular, I see that your 'delete' method seems to be returning the 'deleteResult' variable, which is going to have probably all the nodes that you deleted as a consequence of the API call. Perhaps you wanted to return the 'data' variable instead?






              share|improve this answer



























                0














                0










                0









                Are you sure that your logic is correct? That is the first thing I would check here. In particular, I see that your 'delete' method seems to be returning the 'deleteResult' variable, which is going to have probably all the nodes that you deleted as a consequence of the API call. Perhaps you wanted to return the 'data' variable instead?






                share|improve this answer













                Are you sure that your logic is correct? That is the first thing I would check here. In particular, I see that your 'delete' method seems to be returning the 'deleteResult' variable, which is going to have probably all the nodes that you deleted as a consequence of the API call. Perhaps you wanted to return the 'data' variable instead?







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 17:34









                pgoldweicpgoldweic

                2421 silver badge7 bronze badges




                2421 silver badge7 bronze badges





















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    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%2f55388323%2fvis-js-removing-whole-graph-when-deleting-single-node%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

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript