Using d3 instead of jquery to enter a process form causes a reload of "/"

Gist http://bl.ocks.org/gregsgit/7cbe5a54fdae2492a826 or https://gist.github.com/gregsgit/7cbe5a54fdae2492a826

I am trying to use only d3 instead of d3 and jquery. The back end is node.js + express + http + fs + socket.io. On the front side, the client socket side, d3, jquery, is used.

Replace the following:

$('form').submit(function(){
  socket.emit('sent message', $('#theInput').val());
  $('#theInput').val('');
  return false;
});

with

d3.select("#theForm").on("submit", function() {
  var inp = d3.select("#theInput");
  var v = inp.property("value");
  inp.property("value", "");
  socket.emit('sent message', v);
  return false;
});

causes a reload of "/", which removes this state that I accumulated in index.html.

, node top-level, multidraw-server.js, , "/". jquery "/" , . d3 "/" .

?

+4
1

, false, , event.preventDefault, D3, d3.event.preventDefault() .on("submit", ...).

+6

All Articles