Rapahel Sketchpad not working

2019-08-27 04:45发布

问题:

Below is my code.I have used raphael sketchpad plugin. But I'm unable to draw,I just get blank sketchpad. Why is it so?

<html>
     <head>
          <script type="text/javascript" src="jquery.min.js"></script>
          <script type="text/javascript" src="raphael-min.js"></script>
          <script type="text/javascript" src="json2.js"></script>
          <script type="text/javascript" src="raphael.sketchpad.js"></script>

   <script type="text/javascript">

    $(document).ready(function() {
    var sketchpad = Raphael.sketchpad("editor", {
            height: 260,
            width: 260,
            editing: true

        });

        // When the sketchpad changes, update the input field.
        sketchpad.change(function() {
            $("#data").val(sketchpad.json());
        });

});

</script>
     </head>
    <body>
<input type="hidden" id="data" />
<div id="editor" style="border: 1px solid #aaa; "></div>

<h1> Testing</h1>



    </body>
</html>

When I try to add a stroke,I get a diagonal line.

回答1:

When I used latest version jquery and raphael,it's working for me now. I did below modification

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="raphael-2.0.1.js"></script>