Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test of code initially failed #11

Open
kikosoft opened this issue Mar 20, 2020 · 1 comment
Open

Test of code initially failed #11

kikosoft opened this issue Mar 20, 2020 · 1 comment

Comments

@kikosoft
Copy link

kikosoft commented Mar 20, 2020

The demo here

https://www.jqueryscript.net/demo/Mobile-Drag-Drop-Plugin-jQuery

looked nice so I wanted to try out your code. After downloading your code from github, uploading it to my server, and included the correct files in my code, I discovered it doesn't work. The console says:

Uncaught ReferenceError: define is not defined at draganddrop.js:1

To be clear: I didn't use "Bower", why would I? I've never used it, and there are only two files. I can't find anything concrete on define(), but it seems to me that it is somehow part of "Bower". Could that be true?

I then looked a bit closer at the demo page above, and found that the javascript code there is slightly different. Instead of:

define(['jquery'], function($) {
"use strict";
   .......
});

it uses:

(function($) {
"use strict";
   .......
}(jQuery));

which does seem to work for me. I also saw some other differences in the code, so I copied your github code and used the above piece of code around it. That seems to work fine.

So is this a "Bower" dependency? And why make your code dependent on it? (sorry, I may be old-fashioned, I like to upload the code myself. Makes me feel in control.)

Anyway, now that I have it working I can experiment with it. What I especially like in your demo is the ability to play with nested lists.

PS: The link to the demo page, here on github, goes to the demo source, not a working demo.

@gardiner
Copy link
Owner

Hi, thanks for your feedback. The code is written as a module that can be included into your own code with a tool like require.js or webpack. I have stuck to this convention because it helps me when using the module in my own projects.
If you want to use the code without such a tool you could probably just remove the first and last line of the module and make sure that $ (jquery) is globally available.
Bower is just a dependency management tool that can help you download required libraries for your project. It is not required for this module to work (in fact I don't use it any more at all), it is just a convenience.
Cheers, Ole.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants