Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
388 views
in Technique[技术] by (71.8m points)

javascript - Drag and Drop working in online but not locally?

Kindly see this fiddle: http://jsfiddle.net/hvncN/ This fiddle implements a simple Drag and Drop list and is working fine.

And also when I run the same code using a Wamp Server localhost, it is working fine. But anyhow, when I try to do it locally in my laptop (without wamp server), I am not able to do it.

So, here is the code:

<HTML>
<HEAD>
</HEAD>
<BODY>



<section id="demos">
    <h1>Demos</h1>
    <style>
        #demos section {
            overflow: hidden;
        }
        .sortable {
            width: 310px;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }
        .sortable.grid {
            overflow: hidden;
        }
        .sortable li {
            list-style: none;
            border: 1px solid #CCC;
            background: #F6F6F6;
            color: #1C94C4;
            margin: 5px;
            padding: 5px;
            height: 22px;
        }
        .sortable.grid li {
            line-height: 80px;
            float: left;
            width: 80px;
            height: 80px;
            text-align: center;
        }
        .handle {
            cursor: move;
        }
        .sortable.connected {
            width: 200px;
            min-height: 100px;
            float: left;
        }
        li.disabled {
            opacity: 0.5;
        }
        li.highlight {
            background: #FEE25F;
        }
        li.sortable-placeholder {
            border: 1px dashed #CCC;
            background: none;
        }
    </style>

    <section>
        <h1>Sortable List</h1>
        <ul id="sortable1" class="sortable list">
            <li draggable="true" class style="display: list-item;">Item 1
            <li draggable="true" class style="display: list-item;">Item 2
            <li draggable="true">Item 3
            <li draggable="true">Item 4
            <li draggable="true">Item 5
            <li draggable="true">Item 6
        </ul>
    </section>
</section>
<script src="/html5sortable/jquery-1.7.1.min.js"></script>
    <script src="/html5sortable/jquery.sortable.js"></script>
    <script>
        $(function() {
            $('#sortable1, #sortable2').sortable();
            $('#sortable3').sortable({
                items: ':not(.disabled)'
            });
            $('#sortable-with-handles').sortable({
                handle: '.handle'
            });
            $('#sortable4, #sortable5').sortable({
                connectWith: '.connected'
            });
        });
    </script>
</BODY>
</HTML>

And here is the error in the console log:

Failed to load resource file:///C:/html5sortable/jquery-1.7.1.min.js
Failed to load resource file:///C:/html5sortable/jquery.sortable.js
Uncaught ReferenceError: $ is not defined 

Why is the code working properly on Fiddle and Wamp Server but not when opened Seperately as file:///C:/wamp/www/test.html

I want it to be able to work completely offline, without Wamp Server because I am later going to put all these files into one Hybrid Android App which is supposed to be working offline. What so I do to have it work offline?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is an additional "/" in the relative address that you have defined. Remove it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...