I am a beginner in html and the joint.js library. I have this code and once I saved it as html on my laptop, it is suppose to draw 2 connected rectangles but nothing appears in the browser. I downloaded many libraries and put them in the same folder that has the html page but nothing appear too.
What am I suppose to do? Where can I put the libraries that I want to use in html code?
The libraries that I downloaded are:
- backbone.js
- core.js
- geometry.js
- joint.all.css
- joint.all.js
- joint.all.min.css
- joint.all.min.js
- joint.css
- joint.dia.cell.js
- joint.dia.element.js
- joint.dia.graph.js
- joint.dia.link.js
- joint.dia.paper.js
- joint.js
- joint.min.css
- joint.min.js
- joint.shapes.devs.js
- joint.shapes.devs.min.js
- joint.shapes.erd.js
- joint.shapes.erd.min.js
- joint.shapes.fsa.js
- joint.shapes.fsa.min.js
- joint.shapes.org.js
- joint.shapes.org.min.js
- jquery.js
- jquery.sortElements.js
- lodash.js
- raphael-min.js
- raphael.js
vectorizer.js
<link rel="stylesheet" type="text/css" href="joint.css" /> <script type="text/javascript" src="joint.js" ></script> <script type="text/javascript"> $(function() { var graph = new joint.dia.Graph; var paper = new joint.dia.Paper({ el: $('#myholder'), width: 600, height: 200, model: graph }); var rect = new joint.shapes.basic.Rect({ position: { x: 100, y: 30 }, size: { width: 100, height: 30 }, attrs: { rect: { fill: 'blue' }, text: { text: 'my box', fill: 'white' } } }); var rect2 = rect.clone(); rect2.translate(300); var link = new joint.dia.Link({ source: { id: rect.id }, target: { id: rect2.id } }); graph.addCells([rect, rect2, link]); }) </script> <div id="myholder" > </div>
Thanks to all of you .. The program is working now after I changed the source of the libraries to be website URLs. If I use the once that I downloaded on my computer it does not work again :
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>
<script src= "http://denknix.com/astro/lib/joint/www/build/joint.all.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://www.jointjs.com/downloads/joint.css" />
<script type="text/javascript" src="http://www.jointjs.com/downloads/joint.js" ></script>
<script type="text/javascript">
$(function() {
var graph = new joint.dia.Graph;
var paper = new joint.dia.Paper({
el: $('#myholder'),
width: 600,
height: 200,
model: graph
});
var rect = new joint.shapes.basic.Rect({
position: { x: 100, y: 30 },
size: { width: 100, height: 30 },
attrs: { rect: { fill: 'blue' }, text: { text: 'my box', fill: 'white' } }
});
var rect2 = rect.clone();
rect2.translate(300);
var link = new joint.dia.Link({
source: { id: rect.id },
target: { id: rect2.id }
});
graph.addCells([rect, rect2, link]);
})
</script>
<title>Test</title>
</head>
<body>
<div id="myholder" >
</div>
</body></html>
Note that you don't need the following two files in your example:
This is because jQuery is already included in
joint.js
and the otherjoint.all.min.js
is a very old version of JointJS (0.4).You only need the other two files that you have correctly included:
The problem must lie in how you reference those files once download them to your computer.